Skip to content

Commit

Permalink
Merge pull request #2 from Songmu/fix-help
Browse files Browse the repository at this point in the history
output usage to stdout and normally exit with `-h` option
  • Loading branch information
Songmu committed Dec 27, 2017
2 parents 726a7ba + 774782b commit 0ccb24e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 77 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,10 @@ or

## Options

- `d` destination directory (`./goxz` by default)
- `os`
- os: linux,darwin and windows by default
- `arch`
- arch: arm64 only by default
- `-d` destination directory (`./goxz` by default)
- `-n` application name. by default the directory name is used.
- `-os` linux,darwin and windows by default
- `-arch` arm64 only by default
- `-pv` for speicifing version (optional)
- `-o` output filename
- not available with multiple package building
Expand Down
66 changes: 0 additions & 66 deletions SKETCH.md

This file was deleted.

5 changes: 3 additions & 2 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ func (cl *cli) parseArgs(args []string) (*goxz, error) {
fs := flag.NewFlagSet("goxz", flag.ContinueOnError)
fs.SetOutput(cl.errStream)
fs.Usage = func() {
fmt.Fprintf(cl.errStream, `goxz - Just do cross building and archiving go tools conventionally
fs.SetOutput(cl.outStream)
defer fs.SetOutput(cl.errStream)
fmt.Fprintf(cl.outStream, `goxz - Just do cross building and archiving go tools conventionally
Version: %s (rev: %s/%s)
Expand All @@ -47,7 +49,6 @@ Options:
fs.StringVar(&gx.output, "o", "", "output (optional)")
fs.StringVar(&gx.os, "os", "", "Specify OS (default is 'linux darwin windows')")
fs.StringVar(&gx.arch, "arch", "", "Specify Arch (default is 'amd64')")
// TODO: fs.StringVar(&gx.buildConstraints, "build", "", "Specify build constraints")
fs.StringVar(&gx.buildLdFlags, "build-ldflags", "", "arguments to pass on each go tool link invocation")
fs.StringVar(&gx.buildTags, "build-tags", "", "a space-separated list of build `tags`")
fs.BoolVar(&gx.zipAlways, "z", false, "zip always")
Expand Down
6 changes: 3 additions & 3 deletions goxz.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ const (
func Run(args []string) int {
err := (&cli{outStream: os.Stdout, errStream: os.Stderr}).run(args)
if err != nil {
if err != flag.ErrHelp {
log.Printf("[!!ERROR!!] %s\n", err)
if err == flag.ErrHelp {
return exitCodeOK
}
log.Printf("[!!ERROR!!] %s\n", err)
return exitCodeErr
}
return exitCodeOK
Expand Down Expand Up @@ -104,7 +105,6 @@ func (gx *goxz) init() error {
return err
}

// TODO: implement build constraints
// fill the defaults
if gx.os == "" {
gx.os = "linux darwin windows"
Expand Down
2 changes: 1 addition & 1 deletion goxz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

func TestRun_help(t *testing.T) {
i := Run([]string{"-h"})
if i != exitCodeErr {
if i != exitCodeOK {
t.Errorf("somthing went wrong")
}
}
Expand Down

0 comments on commit 0ccb24e

Please sign in to comment.