~juju/juju-core/trunk

« back to all changes in this revision

Viewing changes to worker/uniter/jujuc/relation-set.go

  • Committer: Tim Penhey
  • Date: 2013-03-14 22:05:40 UTC
  • mfrom: (993.1.10 format-flag)
  • Revision ID: tim.penhey@canonical.com-20130314220540-0o7j2ki1kb46sjp6
Add a --format flag for jujuc commands missing it

Fixes lp:1129130.  Also marks the --format flag as deprecated for commands
that don't produce output.

R=dfc, dimitern
CC=
https://codereview.appspot.com/7795045

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
        ctx        Context
14
14
        RelationId int
15
15
        Settings   map[string]string
 
16
        formatFlag string // deprecated
16
17
}
17
18
 
18
19
func NewRelationSetCommand(ctx Context) cmd.Command {
29
30
 
30
31
func (c *RelationSetCommand) SetFlags(f *gnuflag.FlagSet) {
31
32
        f.Var(newRelationIdValue(c.ctx, &c.RelationId), "r", "specify a relation by id")
 
33
        f.StringVar(&c.formatFlag, "format", "", "deprecated format flag")
32
34
}
33
35
 
34
36
func (c *RelationSetCommand) Init(args []string) error {
49
51
}
50
52
 
51
53
func (c *RelationSetCommand) Run(ctx *cmd.Context) (err error) {
 
54
        if c.formatFlag != "" {
 
55
                fmt.Fprintf(ctx.Stderr, "--format flag deprecated for command %q", c.Info().Name)
 
56
        }
52
57
        r, found := c.ctx.Relation(c.RelationId)
53
58
        if !found {
54
59
                return fmt.Errorf("unknown relation id")