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]
which is equivalent to the longer:
GARBLE_DIR="$PWD" go build -a -trimpath -toolexec=garble [build flags] [packages]
See `garble -h` for up to date usage information.
### Purpose

@ -38,9 +38,13 @@ Usage of garble:
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:])
flagSet.PrintDefaults()
os.Exit(2)
@ -144,7 +148,13 @@ func mainErr(args []string) error {
// If we recognise an argument, we're not running within -toolexec.
switch cmd := args[0]; cmd {
case "help":
flagSet.Usage()
case "build", "test":
switch args[1] {
case "-h", "-help", "--help":
flagSet.Usage()
}
wd, err := os.Getwd()
if err != nil {
return err

@ -1,14 +1,24 @@
! garble
stderr -count=1 'Usage of'
stderr '\tgo build'
stderr -count=1 'Usage of garble'
stderr 'garble cmd'
! stderr 'usage: go build'
! stdout .
! 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 .
! garble -badflag
stderr 'Usage of'
stderr 'Usage of garble'
! stdout .
! garble badcmd

Loading…
Cancel
Save