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

Side by Side Diff: cmd/plugins/juju-metadata/metadata.go

Issue 78660045: cmd: No longer panic if cwd is deleted (Closed)
Patch Set: cmd: No longer panic if cwd is deleted Created 11 years 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/jujud/main.go ('k') | cmd/plugins/juju-restore/restore.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 // 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 "github.com/juju/loggo" 10 "github.com/juju/loggo"
11 11
12 "launchpad.net/juju-core/cmd" 12 "launchpad.net/juju-core/cmd"
13 "launchpad.net/juju-core/juju" 13 "launchpad.net/juju-core/juju"
14 _ "launchpad.net/juju-core/provider/all" 14 _ "launchpad.net/juju-core/provider/all"
15 ) 15 )
16 16
17 var logger = loggo.GetLogger("juju.plugins.metadata") 17 var logger = loggo.GetLogger("juju.plugins.metadata")
18 18
19 var metadataDoc = ` 19 var metadataDoc = `
20 Juju metadata is used to find the correct image and tools when bootstrapping a 20 Juju metadata is used to find the correct image and tools when bootstrapping a
21 Juju environment. 21 Juju environment.
22 ` 22 `
23 23
24 // Main registers subcommands for the juju-metadata executable, and hands over c ontrol 24 // Main registers subcommands for the juju-metadata executable, and hands over c ontrol
25 // to the cmd package. This function is not redundant with main, because it 25 // to the cmd package. This function is not redundant with main, because it
26 // provides an entry point for testing with arbitrary command line arguments. 26 // provides an entry point for testing with arbitrary command line arguments.
27 func Main(args []string) { 27 func Main(args []string) {
28 ctx, err := cmd.DefaultContext()
29 if err != nil {
30 fmt.Fprintf(os.Stderr, "error: %v\n", err)
31 os.Exit(2)
32 }
28 if err := juju.InitJujuHome(); err != nil { 33 if err := juju.InitJujuHome(); err != nil {
29 fmt.Fprintf(os.Stderr, "error: %s\n", err) 34 fmt.Fprintf(os.Stderr, "error: %s\n", err)
30 os.Exit(2) 35 os.Exit(2)
31 } 36 }
32 metadatacmd := cmd.NewSuperCommand(cmd.SuperCommandParams{ 37 metadatacmd := cmd.NewSuperCommand(cmd.SuperCommandParams{
33 Name: "metadata", 38 Name: "metadata",
34 UsagePrefix: "juju", 39 UsagePrefix: "juju",
35 Doc: metadataDoc, 40 Doc: metadataDoc,
36 Purpose: "tools for generating and validating image and tool s metadata", 41 Purpose: "tools for generating and validating image and tool s metadata",
37 Log: &cmd.Log{}}) 42 Log: &cmd.Log{}})
38 43
39 metadatacmd.Register(&ValidateImageMetadataCommand{}) 44 metadatacmd.Register(&ValidateImageMetadataCommand{})
40 metadatacmd.Register(&ImageMetadataCommand{}) 45 metadatacmd.Register(&ImageMetadataCommand{})
41 metadatacmd.Register(&ToolsMetadataCommand{}) 46 metadatacmd.Register(&ToolsMetadataCommand{})
42 metadatacmd.Register(&ValidateToolsMetadataCommand{}) 47 metadatacmd.Register(&ValidateToolsMetadataCommand{})
43 metadatacmd.Register(&SignMetadataCommand{}) 48 metadatacmd.Register(&SignMetadataCommand{})
44 49
45 » os.Exit(cmd.Main(metadatacmd, cmd.DefaultContext(), args[1:])) 50 » os.Exit(cmd.Main(metadatacmd, ctx, args[1:]))
46 } 51 }
47 52
48 func main() { 53 func main() {
49 Main(os.Args) 54 Main(os.Args)
50 } 55 }
OLDNEW
« no previous file with comments | « cmd/jujud/main.go ('k') | cmd/plugins/juju-restore/restore.go » ('j') | no next file with comments »

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