Skip to content

Commit 33df164

Browse files
committed
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.
1 parent 602235e commit 33df164

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"io"
1010
"os"
1111
"sort"
12+
"strings"
1213

1314
"github.com/fatih/color"
1415
"github.com/mattn/go-colorable"
@@ -119,6 +120,11 @@ func main() {
119120
os.Exit(exitOK)
120121
}
121122

123+
// If executed as 'ungron' set the --ungron flag
124+
if strings.HasSuffix(os.Args[0], "ungron") {
125+
ungronFlag = true
126+
}
127+
122128
// Determine what the program's input should be:
123129
// file, HTTP URL or stdin
124130
var rawInput io.Reader

0 commit comments

Comments
 (0)