Skip to content

Commit

Permalink
cleanup ?
Browse files Browse the repository at this point in the history
  • Loading branch information
zakuro9715 committed May 6, 2021
1 parent c7fedd1 commit 1a61f01
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ func fprintVersion(w io.Writer) {
}

// exit_code == -1 means don't exit
func processFlags(nzargs []nzflag.Value) (i int, _ *config.Config, _ *runner.Config, code int) {
func processFlags(nzargs []nzflag.Value) (i int, cfg *config.Config, rconfig *runner.Config, code int) {
configPath := "z.yaml"
if p, ok := os.LookupEnv("ZCONFIG"); ok {
configPath = p
}

helpFlag := false
verboseFlag := isEnvValTrue(os.Getenv(ENV_KEY_ZVERBOSE))
rconfig := &runner.Config{Silent: isEnvValTrue(os.Getenv(ENV_KEY_ZSILENT))}
rconfig = &runner.Config{Silent: isEnvValTrue(os.Getenv(ENV_KEY_ZSILENT))}
for ; i < len(nzargs); i++ {
arg := nzargs[i]
if arg.Type() != nzflag.TypeFlag {
Expand Down Expand Up @@ -138,18 +138,21 @@ parse_end:
log.Info("flags:")
log.Info(" %v", nzargs[0:i])

config, err := config.LoadConfig(configPath)
cfg, err := config.LoadConfig(configPath)
if err != nil {
fmt.Fprintln(os.Stderr, yaml.FormatError(err, true, true))
return i, config, rconfig, 1
code = 1
return
}

if helpFlag {
fprintHelp(os.Stdout, config)
return i, config, rconfig, 0
fprintHelp(os.Stdout, cfg)
code = 0
return
}

return i, config, rconfig, -1
code = -1
return
}

func findTask(i *int, nzargs []nzflag.Value, config *config.Config) (task *config.Task, code int) {
Expand Down

0 comments on commit 1a61f01

Please sign in to comment.