Skip to content

Commit

Permalink
changed: set default output format to json
Browse files Browse the repository at this point in the history
  • Loading branch information
sharo-jef committed Jun 17, 2022
1 parent f754fd8 commit 23f22a2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
csv processor

```
$ cat a.csv
$ cat a.csv -o c
a,b,c,d
o,p,q,r
w,x,y,z
Expand All @@ -16,7 +16,7 @@ $ cq a.csv -o y
b: x
c: "y"
d: z
$ cat a.csv | cq -o j -c
$ cat a.csv | cq -c
[{"a":"o","b":"p","c":"q","d":"r"},{"a":"w","b":"x","c":"y","d":"z"}]
```

Expand Down
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ var rootCmd = &cobra.Command{
header = []string{}
}
of, _ := cmd.Flags().GetString("output-format")
if !StringContains([]string{"csv", "c", "yaml", "y", "json", "j", "xml", "x"}, of) {
if !StringContains([]string{"json", "j", "csv", "c", "yaml", "y" /*, "xml", "x"*/}, of) {
fmt.Printf("Invalid output format: %s\n", of)
os.Exit(6)
}
Expand Down Expand Up @@ -224,7 +224,7 @@ func init() {
rootCmd.PersistentFlags().StringP("field-separator", "F", ",", "field separator")
rootCmd.PersistentFlags().BoolP("compact", "c", false, "compact instead of pretty-printed output")
rootCmd.PersistentFlags().StringP("header", "H", "", "header (comma separated string)")
rootCmd.PersistentFlags().StringP("output-format", "o", "csv", "[csv|c|yaml|y|json|j|xml|x] output format type. (default csv)")
rootCmd.PersistentFlags().StringP("output-format", "o", "json", "[json|j|csv|c|yaml|y|xml|x] output format type. (default json)")
}

// initConfig reads in config file and ENV variables if set.
Expand Down
Binary file added cq.exe
Binary file not shown.

0 comments on commit 23f22a2

Please sign in to comment.