aboutsummaryrefslogtreecommitdiffstats
path: root/hi.go
diff options
context:
space:
mode:
authorRose Hogenson <rosehogenson@posteo.net>2025-07-04 10:47:24 -0700
committerRose Hogenson <rosehogenson@posteo.net>2025-07-04 10:47:24 -0700
commit1d9f7d2fe88deecf958e0199b9d669328a717c17 (patch)
tree9c4f36d57d383be1425f58ab92b1f4f5f64fcf58 /hi.go
parentb0454e1de6ff0cf310b3acb599a7d42d7a079423 (diff)
downloadhi-1d9f7d2fe88deecf958e0199b9d669328a717c17.tar.zst
Better documentation
Diffstat (limited to 'hi.go')
-rw-r--r--hi.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/hi.go b/hi.go
index ec927b3..7d3370a 100644
--- a/hi.go
+++ b/hi.go
@@ -90,16 +90,16 @@ func (c *colorFlag) String() string {
func run() error {
args := flag.Args()
if len(args) == 0 {
- fmt.Fprintf(os.Stderr, "missing regexp to highlight\n")
+ fmt.Fprintf(os.Stderr, "hi: missing regexp to highlight\n")
flag.Usage()
}
if len(args) > 2 {
- fmt.Fprintf(os.Stderr, "too many positional arguments\n")
+ fmt.Fprintf(os.Stderr, "hi: too many positional arguments\n")
flag.Usage()
}
highlightRE, err := regexp.CompilePOSIX(args[0])
if err != nil {
- return fmt.Errorf("invalid highlight regexp: %s", err)
+ return fmt.Errorf("invalid highlight regexp: %s\n", err)
}
foregroundColor := highlightColor.Foreground()
backgroundColor := background.Background()
@@ -119,8 +119,17 @@ func run() error {
func main() {
flag.Usage = func() {
- fmt.Fprintf(os.Stderr, "Usage: hi [OPTIONS] REGEXP\n")
+ fmt.Fprintf(os.Stderr, `Usage: hi [OPTION]... REGEXP
+Highlight lines from standard input using the given regexp.
+
+`)
flag.PrintDefaults()
+ fmt.Fprintf(os.Stderr, `
+Examples:
+ echo 1\n2\n3 | hi ^2
+
+ journalctl | hi -bg cyan (E|e)rror | less
+`)
os.Exit(2)
}
flag.Parse()