clarify usage text, add help flags

Also remove the -toolexec equivalent, as it's becoming longer now that
we have GARBLE_DIR, and it might become out of date in the future again.
We don't want users to assume it will work forever.
pull/22/head
Daniel Martí 4 years ago
parent 19e4c098cd
commit 1ef3daf251

@ -6,9 +6,7 @@ Obfuscate a Go build. Requires Go 1.13 or later.
garble build [build flags] [packages] garble build [build flags] [packages]
which is equivalent to the longer: See `garble -h` for up to date usage information.
GARBLE_DIR="$PWD" go build -a -trimpath -toolexec=garble [build flags] [packages]
### Purpose ### Purpose

@ -38,9 +38,13 @@ Usage of garble:
garble build [build flags] [packages] garble build [build flags] [packages]
which is equivalent to the longer: The tool supports wrapping the following Go commands - run "garble cmd [args]"
instead of "go cmd [args]" to add obfuscation:
go build -a -trimpath -toolexec=garble [build flags] [packages] build
test
garble does not have flags of its own at this moment.
`[1:]) `[1:])
flagSet.PrintDefaults() flagSet.PrintDefaults()
os.Exit(2) os.Exit(2)
@ -144,7 +148,13 @@ func mainErr(args []string) error {
// If we recognise an argument, we're not running within -toolexec. // If we recognise an argument, we're not running within -toolexec.
switch cmd := args[0]; cmd { switch cmd := args[0]; cmd {
case "help":
flagSet.Usage()
case "build", "test": case "build", "test":
switch args[1] {
case "-h", "-help", "--help":
flagSet.Usage()
}
wd, err := os.Getwd() wd, err := os.Getwd()
if err != nil { if err != nil {
return err return err

@ -1,14 +1,24 @@
! garble ! garble
stderr -count=1 'Usage of' stderr -count=1 'Usage of garble'
stderr '\tgo build' stderr 'garble cmd'
! stderr 'usage: go build'
! stdout . ! stdout .
! garble -h ! garble -h
stderr 'Usage of' stderr 'Usage of garble'
! stdout .
! garble help
stderr 'Usage of garble'
! stdout .
! garble build -h
stderr 'Usage of garble'
! stderr 'usage: go build'
! stdout . ! stdout .
! garble -badflag ! garble -badflag
stderr 'Usage of' stderr 'Usage of garble'
! stdout . ! stdout .
! garble badcmd ! garble badcmd

Loading…
Cancel
Save