11package  v7
22
33import  (
4+ 	"code.cloudfoundry.org/cli/actor/v7action" 
45	"code.cloudfoundry.org/cli/command/flag" 
56	"code.cloudfoundry.org/cli/command/v7/shared" 
67)
78
9+ type  AppDisplayer  interface  {
10+ 	AppDisplay (summary  v7action.DetailedApplicationSummary , displayStartCommand  bool )
11+ }
12+ 
813type  AppCommand  struct  {
914	BaseCommand 
1015
1116	RequiredArgs     flag.AppName  `positional-args:"yes"` 
1217	GUID             bool          `long:"guid" description:"Retrieve and display the given app's guid.  All other health and status output for the app is suppressed."` 
1318	usage            interface {}  `usage:"CF_NAME app APP_NAME [--guid]"` 
1419	relatedCommands  interface {}  `related_commands:"apps, events, logs, map-route, unmap-route, push"` 
20+ 	JSONOutput       bool          `long:"json" description:"Output in json form"` 
1521}
1622
1723func  (cmd  AppCommand ) Execute (args  []string ) error  {
@@ -29,15 +35,18 @@ func (cmd AppCommand) Execute(args []string) error {
2935		return  err 
3036	}
3137
32- 	cmd .UI .DisplayTextWithFlavor ("Showing health and status for app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}..." , map [string ]interface {}{
33- 		"AppName" :   cmd .RequiredArgs .AppName ,
34- 		"OrgName" :   cmd .Config .TargetedOrganization ().Name ,
35- 		"SpaceName" : cmd .Config .TargetedSpace ().Name ,
36- 		"Username" :  user .Name ,
37- 	})
38- 	cmd .UI .DisplayNewline ()
38+ 	var  appSummaryDisplayer  AppDisplayer  =  shared .NewAppSummaryJSONDisplayer (cmd .UI )
39+ 	if  ! cmd .JSONOutput  {
40+ 		cmd .UI .DisplayTextWithFlavor ("Showing health and status for app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}..." , map [string ]interface {}{
41+ 			"AppName" :   cmd .RequiredArgs .AppName ,
42+ 			"OrgName" :   cmd .Config .TargetedOrganization ().Name ,
43+ 			"SpaceName" : cmd .Config .TargetedSpace ().Name ,
44+ 			"Username" :  user .Name ,
45+ 		})
46+ 		cmd .UI .DisplayNewline ()
47+ 		appSummaryDisplayer  =  shared .NewAppSummaryDisplayer (cmd .UI )
48+ 	}
3949
40- 	appSummaryDisplayer  :=  shared .NewAppSummaryDisplayer (cmd .UI )
4150	summary , warnings , err  :=  cmd .Actor .GetDetailedAppSummary (cmd .RequiredArgs .AppName , cmd .Config .TargetedSpace ().GUID , false )
4251	cmd .UI .DisplayWarnings (warnings )
4352	if  err  !=  nil  {
@@ -55,6 +64,10 @@ func (cmd AppCommand) displayAppGUID() error {
5564		return  err 
5665	}
5766
67+ 	if  cmd .JSONOutput  {
68+ 		return  cmd .UI .DisplayJSON ("" , map [string ]string {"guid" : app .GUID })
69+ 	}
70+ 
5871	cmd .UI .DisplayText (app .GUID )
5972	return  nil 
6073}
0 commit comments