Cli: NewExitError not working

Created on 2 May 2016  路  2Comments  路  Source: urfave/cli

I'm trying to get an cli app to error out when certain requirements are not met.
I've been unsuccessful.
I've come to the conclusing the NewExitError is not working at all.

I've compiled the provided Error example from the readme.

package main

import (
  "os"

  "github.com/codegangsta/cli"
)

func main() {
  app := cli.NewApp()
  app.Flags = []cli.Flag{
    cli.BoolTFlag{
      Name:  "ginger-crouton",
      Usage: "is it in the soup?",
    },
  }
  app.Action = func(ctx *cli.Context) error {
    if !ctx.Bool("ginger-crouton") {
      return cli.NewExitError("it is not in the soup", 86)
    }
    return nil
  }

  app.Run(os.Args)
}

OS: Windows 7 Enterprise
GO: 1.6.2

Expected Terminal Output: "it is not in the soup"
Expected Windows RETVAL (%ERRORLEVEL%): 86

Current output: Nothing
Current Windows RETVAL (%ERRORLEVEL%): 0

I've already checked my Go ENV; Also redownloaded the package.
Can someone please confirm this issue for me by also compiling and running the error example from the README.

kinbug

Most helpful comment

I think I found the origin of the problem, will create branch for pull request

All 2 comments

I think I found the origin of the problem, will create branch for pull request

You're fix looks more complete :+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

errashe picture errashe  路  3Comments

mponton picture mponton  路  5Comments

millken picture millken  路  5Comments

Zyko0 picture Zyko0  路  6Comments

vschettino picture vschettino  路  5Comments