Skip to content

Commit

Permalink
Allow running as ungron to perform --ungron automatically
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alblue committed Nov 6, 2020
1 parent 602235e commit 33df164
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io"
"os"
"sort"
"strings"

"github.com/fatih/color"
"github.com/mattn/go-colorable"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 33df164

Please sign in to comment.