Skip to content
This repository was archived by the owner on Dec 13, 2025. It is now read-only.

Commit 8c87da3

Browse files
authored
show short help with -h (#76)
1 parent 6f0f5af commit 8c87da3

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

cfg/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
)
2929

3030
const DefaultSeparator string = `(\s\s+|\t)`
31-
const Version string = "v1.5.6"
31+
const Version string = "v1.5.7"
3232
const MAXPARTS = 2
3333

3434
var DefaultConfigfile = os.Getenv("HOME") + "/.config/tablizer/config"

cmd/root.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"errors"
2121
"fmt"
2222
"os"
23+
"slices"
2324
"strings"
2425

2526
"github.com/spf13/cobra"
@@ -187,6 +188,11 @@ func Execute() {
187188

188189
rootCmd.SetUsageTemplate(strings.TrimSpace(usage) + "\n")
189190

191+
if slices.Contains(os.Args, "-h") {
192+
fmt.Println(shortusage)
193+
os.Exit(0)
194+
}
195+
190196
err := rootCmd.Execute()
191197
if err != nil {
192198
os.Exit(1)

cmd/shortusage.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package cmd
2+
3+
const shortusage = `tablizer [regex,...] [-r file] [flags]
4+
-c col,... show specified columns -L highlight matching lines
5+
-k col,... sort by specified columns -j read JSON input
6+
-F col=reg filter field with regexp -v invert match
7+
-T col,... transpose specified columns -n numberize columns
8+
-R /from/to/ apply replacement to columns in -T -N do not use colors
9+
-y col,... yank columns to clipboard -H do not show headers
10+
--ofs char output field separator -s specify field separator
11+
-r file read input from file -z use fuzzy search
12+
-f file read config from file -I interactive filter mode
13+
-d debug
14+
-O org -C CSV -M md -X ext -S shell -Y yaml -D sort descending order
15+
-m show manual --help show detailed help -v show version
16+
-a sort by age -i sort numerically -t sort by time`

t/test-basics.txtar

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# usage
2-
exec tablizer -h
2+
exec tablizer --help
33
stdout Usage
44

5+
exec tablizer -h
6+
stdout show
7+
58
# version
69
exec tablizer -V
710
stdout version

0 commit comments

Comments
 (0)