From 33df164523e0e541d8b6f2843b9469b38e29ed33 Mon Sep 17 00:00:00 2001 From: Alex Blewitt Date: Fri, 6 Nov 2020 16:51:02 +0000 Subject: [PATCH] Allow running as ungron to perform --ungron automatically The executable is normally executed as `gron` which performs the gron operation. However, in order to install it as `ungron`, an alias is not necessary as a symbolic link can be used instead. When the program detects that it is being run as an executable called `ungron` then it will automatically set the `--ungron` argument. --- main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.go b/main.go index 840e36a..be6ad56 100644 --- a/main.go +++ b/main.go @@ -9,6 +9,7 @@ import ( "io" "os" "sort" + "strings" "github.com/fatih/color" "github.com/mattn/go-colorable" @@ -119,6 +120,11 @@ func main() { os.Exit(exitOK) } + // If executed as 'ungron' set the --ungron flag + if strings.HasSuffix(os.Args[0], "ungron") { + ungronFlag = true + } + // Determine what the program's input should be: // file, HTTP URL or stdin var rawInput io.Reader