github.com/bhameyie/otto@v0.2.1-0.20160406174117-16052efa52ec/command/status.go (about) 1 package command 2 3 import ( 4 "fmt" 5 "strings" 6 ) 7 8 // StatusCommand is the command that shows the status of the various 9 // stages of this application. 10 type StatusCommand struct { 11 Meta 12 } 13 14 func (c *StatusCommand) Run(args []string) int { 15 fs := c.FlagSet("status", FlagSetNone) 16 fs.Usage = func() { c.Ui.Error(c.Help()) } 17 if err := fs.Parse(args); err != nil { 18 return 1 19 } 20 21 // Load the appfile 22 app, err := c.Appfile() 23 if err != nil { 24 c.Ui.Error(err.Error()) 25 return 1 26 } 27 28 // Get a core 29 core, err := c.Core(app) 30 if err != nil { 31 c.Ui.Error(fmt.Sprintf( 32 "Error loading core: %s", err)) 33 return 1 34 } 35 36 // Execute the task 37 err = core.Status() 38 if err != nil { 39 c.Ui.Error(fmt.Sprintf( 40 "Error occurred: %s", err)) 41 return 1 42 } 43 44 return 0 45 } 46 47 func (c *StatusCommand) Synopsis() string { 48 return "Status of the stages of this application" 49 } 50 51 func (c *StatusCommand) Help() string { 52 helpText := ` 53 Usage: otto status 54 55 Shows the status of this application. 56 57 This command will show whether an application has a development 58 environment created, a build made, a deploy done, the infrastructure 59 ready, etc. 60 61 The output from this command is loaded from a cache and may not represent 62 the true state of the world if external changes have happened outside of 63 Otto. For a true status, the actual command to manage each thing must 64 be run. For example, for development "otto dev" should be run. 65 66 ` 67 68 return strings.TrimSpace(helpText) 69 }