#37: add tab output format: --out-format=tab

This commit is contained in:
Denis Isaev 2018-06-02 20:53:36 +03:00
parent 1e0cacf411
commit f62d607410
No known key found for this signature in database
GPG key ID: A36A0EC8E27A1A01
4 changed files with 80 additions and 7 deletions

View file

@ -235,12 +235,19 @@ func (e *Executor) runAndPrint(ctx context.Context, args []string) error {
}
var p printers.Printer
if e.cfg.Output.Format == config.OutFormatJSON {
format := e.cfg.Output.Format
switch format {
case config.OutFormatJSON:
p = printers.NewJSON()
} else {
case config.OutFormatColoredLineNumber, config.OutFormatLineNumber:
p = printers.NewText(e.cfg.Output.PrintIssuedLine,
e.cfg.Output.Format == config.OutFormatColoredLineNumber, e.cfg.Output.PrintLinterName)
format == config.OutFormatColoredLineNumber, e.cfg.Output.PrintLinterName)
case config.OutFormatTab:
p = printers.NewTab(e.cfg.Output.PrintLinterName)
default:
return fmt.Errorf("unknown output format %s", format)
}
gotAnyIssues, err := p.Print(ctx, issues)
if err != nil {
return fmt.Errorf("can't print %d issues: %s", len(issues), err)
@ -296,6 +303,7 @@ func (e *Executor) parseConfig() {
e.initFlagSet(fs)
e.initRootFlagSet(fs)
fs.Usage = func() {} // otherwise help text will be printed twice
if err := fs.Parse(os.Args); err != nil {
if err == pflag.ErrHelp {
return