Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 // Copyright 2012, 2013 Canonical Ltd. | 1 // Copyright 2012, 2013 Canonical Ltd. |
2 // Licensed under the AGPLv3, see LICENCE file for details. | 2 // Licensed under the AGPLv3, see LICENCE file for details. |
3 | 3 |
4 package main | 4 package main |
5 | 5 |
6 import ( | 6 import ( |
7 "fmt" | 7 "fmt" |
8 "os" | 8 "os" |
9 | 9 |
10 "launchpad.net/juju-core/cmd" | 10 "launchpad.net/juju-core/cmd" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 | 116 |
117 // envCmdWrapper is a struct that wraps an environment command and lets us handl e | 117 // envCmdWrapper is a struct that wraps an environment command and lets us handl e |
118 // errors returned from Run before they're returned to the main function | 118 // errors returned from Run before they're returned to the main function |
119 type envCmdWrapper struct { | 119 type envCmdWrapper struct { |
120 envCmd | 120 envCmd |
121 } | 121 } |
122 | 122 |
123 // Run in envCmdWrapper gives us an opportunity to handle errors after the comma nd is | 123 // Run in envCmdWrapper gives us an opportunity to handle errors after the comma nd is |
124 // run. This is used to give informative messages to the user. | 124 // run. This is used to give informative messages to the user. |
125 func (c envCmdWrapper) Run(ctx *cmd.Context) error { | 125 func (c envCmdWrapper) Run(ctx *cmd.Context) error { |
126 err := c.envCmd.Run(ctx) | 126 err := c.envCmd.Run(ctx) |
rog
2013/08/08 17:25:41
if !environs.IsNoEnv(err) || c.EnvironName() != ""
| |
127 if environs.IsNoEnv(err) && c.EnvironName() == "" { | 127 if environs.IsNoEnv(err) && c.EnvironName() == "" { |
128 fmt.Fprintln(ctx.Stderr, "No juju environment configuration file exists.") | 128 fmt.Fprintln(ctx.Stderr, "No juju environment configuration file exists.") |
129 » » fmt.Fprintln(ctx.Stderr, err.Error()) | 129 » » fmt.Fprintln(ctx.Stderr, err) |
rog
2013/08/08 17:25:41
s/.Error()//
| |
130 fmt.Fprintln(ctx.Stderr, "Please create a configuration by runni ng:") | 130 fmt.Fprintln(ctx.Stderr, "Please create a configuration by runni ng:") |
131 fmt.Fprintln(ctx.Stderr, " juju init -w") | 131 fmt.Fprintln(ctx.Stderr, " juju init -w") |
132 fmt.Fprintln(ctx.Stderr, "then edit the file to configure your j uju environment.") | 132 fmt.Fprintln(ctx.Stderr, "then edit the file to configure your j uju environment.") |
133 fmt.Fprintln(ctx.Stderr, "You can then re-run the command.") | 133 fmt.Fprintln(ctx.Stderr, "You can then re-run the command.") |
134 return cmd.ErrSilent | 134 return cmd.ErrSilent |
135 } | 135 } |
136 | 136 |
137 return err | 137 return err |
138 } | 138 } |
139 | 139 |
140 func main() { | 140 func main() { |
141 Main(os.Args) | 141 Main(os.Args) |
142 } | 142 } |
LEFT | RIGHT |