Skip to content

Commit

Permalink
Merge pull request #10 from noborus/remove-short-option
Browse files Browse the repository at this point in the history
Removed short options for out-*
  • Loading branch information
noborus authored Nov 20, 2023
2 parents 8314e0f + 1d33257 commit c9c8a92
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cmd/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func setWriter(fileName string) (trdsql.Writer, error) {

// XLSX Writer
if fileName == "" {
return nil, fmt.Errorf("a valid file name is required to output in XLSX format")
return nil, fmt.Errorf("a valid file name (--out-file) is required to output in XLSX format")
}

if OutSheetName == "" {
Expand Down
22 changes: 14 additions & 8 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ Output to CSV and various formats.`,
fmt.Printf("xlsxsql version %s rev:%s\n", Version, Revision)
return
}
cmd.Help()
if err := cmd.Help(); err != nil {
cmd.SetOutput(os.Stderr)
os.Exit(1)
}
},
}

Expand All @@ -38,7 +41,6 @@ func Execute(version string, revision string) {
Revision = revision
if err := rootCmd.Execute(); err != nil {
rootCmd.SetOutput(os.Stderr)
rootCmd.Println(err)
os.Exit(1)
}
}
Expand Down Expand Up @@ -76,12 +78,16 @@ var ClearSheet bool
func init() {
rootCmd.PersistentFlags().BoolVarP(&Ver, "version", "v", false, "display version information")
rootCmd.PersistentFlags().BoolVarP(&Debug, "debug", "", false, "debug mode")

// Input
rootCmd.PersistentFlags().IntVarP(&Skip, "skip", "s", 0, "Skip the number of lines")
rootCmd.PersistentFlags().BoolVarP(&Header, "header", "H", false, "Input header")
rootCmd.PersistentFlags().BoolVarP(&OutHeader, "out-header", "O", false, "Output header")
rootCmd.PersistentFlags().StringVarP(&OutFormat, "out", "o", "GUESS", "Output Format[CSV|AT|LTSV|JSON|JSONL|TBLN|RAW|MD|VF|YAML]")
rootCmd.PersistentFlags().StringVarP(&OutFileName, "out-xlsx", "x", "", "File name to output to xlsx file")
rootCmd.PersistentFlags().StringVarP(&OutSheetName, "out-sheet", "S", "", "Sheet name to output to xlsx file")
rootCmd.PersistentFlags().StringVarP(&OutCell, "out-cell", "C", "", "Cell name to output to xlsx file")
rootCmd.PersistentFlags().BoolVarP(&ClearSheet, "clear-sheet", "D", false, "Clear sheet when outputting to xlsx file")

// Output
rootCmd.PersistentFlags().StringVarP(&OutFormat, "out", "o", "GUESS", "Output Format[CSV|AT|LTSV|JSON|JSONL|TBLN|RAW|MD|VF|YAML|XLSX]")
rootCmd.PersistentFlags().StringVarP(&OutFileName, "out-file", "O", "", "File name to output to file")
rootCmd.PersistentFlags().BoolVarP(&OutHeader, "out-header", "", false, "Output header")
rootCmd.PersistentFlags().StringVarP(&OutSheetName, "out-sheet", "", "", "Sheet name to output to xlsx file")
rootCmd.PersistentFlags().StringVarP(&OutCell, "out-cell", "", "", "Cell name to output to xlsx file")
rootCmd.PersistentFlags().BoolVarP(&ClearSheet, "clear-sheet", "", false, "Clear sheet when outputting to xlsx file")
}

0 comments on commit c9c8a92

Please sign in to comment.