Skip to content

CSV出力でJSONが出力される — tableがnilでfallback #2

@shannon0430

Description

@shannon0430

バグ

jpn law search "民法" -o csv
→ JSON形式で出力される(CSVではない)

原因

cmd/law.go 等で FormatTable 以外の時に table をnilで output.Print() に渡している。formatter.goFormatCSV はtable==nilの時JSONにfallbackする仕様。

修正方針

テーブル構築をformat判定の外に出す:

// Before
if format == output.FormatTable {
    table := &output.Table{...}
    return output.Print(format, resp, table)
}
return output.Print(format, resp, nil)

// After
table := &output.Table{...}
return output.Print(format, resp, table)

law, subsidy, corp, invoice, edinet, gbiz, realestate, patent の全searchコマンドに適用が必要。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions