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

Side by Side Diff: cmd/juju/ssh.go

Issue 7338048: This branch refactors the Command interface.
Patch Set: This branch refactors the Command interface. Created 12 years, 1 month 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:
View unified diff | Download patch
« no previous file with comments | « cmd/juju/set.go ('k') | cmd/juju/status.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 package main 1 package main
2 2
3 import ( 3 import (
4 "errors" 4 "errors"
5 "fmt" 5 "fmt"
6 "launchpad.net/gnuflag" 6 "launchpad.net/gnuflag"
7 "launchpad.net/juju-core/cmd" 7 "launchpad.net/juju-core/cmd"
8 "launchpad.net/juju-core/juju" 8 "launchpad.net/juju-core/juju"
9 "launchpad.net/juju-core/log" 9 "launchpad.net/juju-core/log"
10 "launchpad.net/juju-core/state" 10 "launchpad.net/juju-core/state"
(...skipping 10 matching lines...) Expand all
21 EnvName string 21 EnvName string
22 Target string 22 Target string
23 Args []string 23 Args []string
24 *juju.Conn 24 *juju.Conn
25 } 25 }
26 26
27 func (c *SSHCommand) Info() *cmd.Info { 27 func (c *SSHCommand) Info() *cmd.Info {
28 return &cmd.Info{"ssh", "", "launch an ssh shell on a given unit or mach ine", ""} 28 return &cmd.Info{"ssh", "", "launch an ssh shell on a given unit or mach ine", ""}
29 } 29 }
30 30
31 func (c *SSHCommand) Init(f *gnuflag.FlagSet, args []string) error { 31 func (c *SSHCommand) SetFlags(f *gnuflag.FlagSet) {
32 addEnvironFlags(&c.EnvName, f) 32 addEnvironFlags(&c.EnvName, f)
33 » if err := f.Parse(true, args); err != nil { 33 }
34 » » return err 34
35 » } 35 func (c *SSHCommand) Init(args []string) error {
36 » args = f.Args()
37 if len(args) == 0 { 36 if len(args) == 0 {
38 return errors.New("no service name specified") 37 return errors.New("no service name specified")
39 } 38 }
40 c.Target, c.Args = args[0], args[1:] 39 c.Target, c.Args = args[0], args[1:]
41 return nil 40 return nil
42 } 41 }
43 42
44 // Run resolves c.Target to a machine, to the address of a i 43 // Run resolves c.Target to a machine, to the address of a i
45 // machine or unit forks ssh passing any arguments provided. 44 // machine or unit forks ssh passing any arguments provided.
46 func (c *SSHCommand) Run(ctx *cmd.Context) error { 45 func (c *SSHCommand) Run(ctx *cmd.Context) error {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } 102 }
104 return inst[0].WaitDNSName() 103 return inst[0].WaitDNSName()
105 } 104 }
106 // BUG(dfc) this does not refresh the machine, so 105 // BUG(dfc) this does not refresh the machine, so
107 // this loop will loop forever if it gets to this point. 106 // this loop will loop forever if it gets to this point.
108 // https://bugs.launchpad.net/juju-core/+bug/1130051 107 // https://bugs.launchpad.net/juju-core/+bug/1130051
109 } 108 }
110 // oops, watcher closed before we could get an answer 109 // oops, watcher closed before we could get an answer
111 return "", w.Stop() 110 return "", w.Stop()
112 } 111 }
OLDNEW
« no previous file with comments | « cmd/juju/set.go ('k') | cmd/juju/status.go » ('j') | no next file with comments »

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