~dave-cheney/juju-core/102-cmd-init-context

« back to all changes in this revision

Viewing changes to cmd/cmd.go

  • Committer: Dave Cheney
  • Date: 2012-09-18 11:37:18 UTC
  • Revision ID: david.cheney@canonical.com-20120918113718-nf0nt6m9s4zskh50
add context to command.init

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
        // Init initializes the Command before running. The command may add options
26
26
        // to f before processing args.
27
 
        Init(f *gnuflag.FlagSet, args []string) error
 
27
        Init(f *gnuflag.FlagSet, args []string, ctx *Context) error
28
28
 
29
29
        // Run will execute the Command as directed by the options and positional
30
30
        // arguments passed to Init.
100
100
func Main(c Command, ctx *Context, args []string) int {
101
101
        f := gnuflag.NewFlagSet(c.Info().Name, gnuflag.ContinueOnError)
102
102
        f.SetOutput(ioutil.Discard)
103
 
        if err := c.Init(f, args); err != nil {
 
103
        if err := c.Init(f, args, ctx); err != nil {
104
104
                if err == gnuflag.ErrHelp {
105
105
                        ctx.Stderr.Write(c.Info().Help(f))
106
106
                        return 0