New constructs an App from Options.
(opts Options)
| 29 | |
| 30 | // New constructs an App from Options. |
| 31 | func New(opts Options) *App { |
| 32 | if opts.Version == "" { |
| 33 | opts.Version = "dev" |
| 34 | } |
| 35 | if opts.Stdout == nil { |
| 36 | opts.Stdout = os.Stdout |
| 37 | } |
| 38 | if opts.Stderr == nil { |
| 39 | opts.Stderr = os.Stderr |
| 40 | } |
| 41 | if opts.Stdin == nil { |
| 42 | opts.Stdin = os.Stdin |
| 43 | } |
| 44 | return &App{version: opts.Version, stdout: opts.Stdout, stderr: opts.Stderr, stdin: opts.Stdin} |
| 45 | } |
| 46 | |
| 47 | // Run executes the CLI and returns the process exit code. errEndpointsHandled |
| 48 | // from PersistentPreRunE is translated to a successful exit so the global |