Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(22)

Delta Between Two Patch Sets: cmd/jujud/unit.go

Issue 5901058: cmd/juju: working bootstrap and destroy commands
Left Patch Set: cmd/juju: working bootstrap and destroy commands Created 13 years ago
Right Patch Set: cmd/juju: working bootstrap and destroy commands Created 12 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « cmd/jujud/provisioning.go ('k') | cmd/jujud/util_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 package main 1 package main
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 "launchpad.net/gnuflag" 5 "launchpad.net/gnuflag"
6 "launchpad.net/juju/go/cmd"
6 "launchpad.net/juju/go/juju" 7 "launchpad.net/juju/go/juju"
7 ) 8 )
8 9
9 // UnitAgent is a cmd.Command responsible for running a unit agent. 10 // UnitAgent is a cmd.Command responsible for running a unit agent.
10 type UnitAgent struct { 11 type UnitAgent struct {
11 agentConf 12 agentConf
12 UnitName string 13 UnitName string
13 } 14 }
14 15
15 func NewUnitAgent() *UnitAgent { 16 func NewUnitAgent() *UnitAgent {
16 return &UnitAgent{agentConf: agentConf{name: "unit"}} 17 return &UnitAgent{agentConf: agentConf{name: "unit"}}
17 } 18 }
18 19
19 // InitFlagSet prepares a FlagSet. 20 // Init initializes the command for running.
20 func (a *UnitAgent) InitFlagSet(f *gnuflag.FlagSet) { 21 func (a *UnitAgent) Init(f *gnuflag.FlagSet, args []string) error {
21 f.StringVar(&a.UnitName, "unit-name", "", "name of the unit to run") 22 f.StringVar(&a.UnitName, "unit-name", "", "name of the unit to run")
22 » a.agentConf.InitFlagSet(f) 23 » if err := a.agentConf.Init(f, args); err != nil {
23 } 24 » » return err
24 25 » }
25 // ParsePositional checks that there are no unwanted arguments, and that all
26 // required flags have been set.
27 func (a *UnitAgent) ParsePositional(args []string) error {
28 if a.UnitName == "" { 26 if a.UnitName == "" {
29 return requiredError("unit-name") 27 return requiredError("unit-name")
30 } 28 }
31 if !juju.ValidUnit.MatchString(a.UnitName) { 29 if !juju.ValidUnit.MatchString(a.UnitName) {
32 return fmt.Errorf(`--unit-name option expects "<service>/<n>" ar gument`) 30 return fmt.Errorf(`--unit-name option expects "<service>/<n>" ar gument`)
33 } 31 }
34 » return a.agentConf.ParsePositional(args) 32 » return nil
35 } 33 }
36 34
37 // Run runs a unit agent. 35 // Run runs a unit agent.
38 func (a *UnitAgent) Run() error { 36 func (a *UnitAgent) Run(_ *cmd.Context) error {
39 return fmt.Errorf("UnitAgent.Run not implemented") 37 return fmt.Errorf("UnitAgent.Run not implemented")
40 } 38 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b