diff --git a/cmd/status/cmd.go b/cmd/status/cmd.go index 03a8612..380f8be 100644 --- a/cmd/status/cmd.go +++ b/cmd/status/cmd.go @@ -24,9 +24,8 @@ const longFormat = `Get an overview of the status of all workloads related to an var long = fmt.Sprintf(longFormat, usage.AppIdentifier(cmdActionText), usage.AppDirectoryArgument) var cmdArgs struct { - orgSlug string - appSlug string - appDir string + appIdent args.AppIdentifierArg + appDir string } var Cmd = &cobra.Command{ @@ -42,10 +41,15 @@ func run(cmd *cobra.Command, args []string) error { input := statusInput{ appDir: cmdArgs.appDir, - appSlug: cmdArgs.appSlug, - orgSlug: cmdArgs.orgSlug, + appSlug: cmdArgs.appIdent.AppSlug, + orgSlug: cmdArgs.appIdent.OrganizationSlug, } err := status(cmd.Context(), service, input) return errorhandling.ErrorAlreadyPrinted(err) } + +func init() { + flags := Cmd.Flags() + cmdArgs.appIdent.AddAppIdentifierFlags(flags, cmdActionText) +} diff --git a/cmd/status/status.go b/cmd/status/status.go index b6ce997..4d612e7 100644 --- a/cmd/status/status.go +++ b/cmd/status/status.go @@ -34,12 +34,22 @@ func status(ctx context.Context, apps appReaderWorkloadLister, input statusInput return err } - workloads, err := apps.ListAppWorkloads(ctx, app.ListAppWorkloadsInput(readOutput)) + println("Name: " + readOutput.AppDisplayName) + if readOutput.AppDescription != "" { + println("Description: " + readOutput.AppDescription) + } + + workloads, err := apps.ListAppWorkloads(ctx, app.ListAppWorkloadsInput{AppID: readOutput.AppID}) if err != nil { app.PrintAppError(err, ai) return err } + println() + if len(workloads) == 0 { + println("No workloads found") + } + printWorkloads(workloads) return nil diff --git a/internal/app/app_read.go b/internal/app/app_read.go index 0c11466..ff8d909 100644 --- a/internal/app/app_read.go +++ b/internal/app/app_read.go @@ -12,20 +12,26 @@ type ReadAppInput struct { } type ReadAppOutput struct { - AppID string + AppID string + AppDisplayName string + AppDescription string } const queryAppText = ` query CLIAppRead($orgSlug: String!, $appSlug: String!) { app(organizationSlug: $orgSlug, appSlug: $appSlug) { id + displayName + description } } ` type appResponse struct { App struct { - ID string + ID string + DisplayName string + Description string } } @@ -35,7 +41,7 @@ func (s *Service) ReadApp(ctx context.Context, input ReadAppInput) (ReadAppOutpu variables := map[string]any{"orgSlug": input.OrganizationSlug, "appSlug": input.AppSlug} err := s.client.Exec(ctx, queryAppText, &resp, variables, graphql.OperationName("CLIAppRead")) if err == nil { - return ReadAppOutput{AppID: resp.App.ID}, nil + return ReadAppOutput{AppID: resp.App.ID, AppDisplayName: resp.App.DisplayName, AppDescription: resp.App.Description}, nil } return ReadAppOutput{}, convertErrors(err) diff --git a/internal/app/app_read_test.go b/internal/app/app_read_test.go index 7d8b615..4c9b8ee 100644 --- a/internal/app/app_read_test.go +++ b/internal/app/app_read_test.go @@ -20,7 +20,9 @@ func TestAppRead(t *testing.T) { { "data": { "app": { - "id": "some-app-id" + "id": "some-app-id", + "displayName": "App Name", + "description": "App description" } } } @@ -35,7 +37,9 @@ func TestAppRead(t *testing.T) { output, err := s.ReadApp(context.TODO(), input) expected := ReadAppOutput{ - AppID: "some-app-id", + AppID: "some-app-id", + AppDisplayName: "App Name", + AppDescription: "App description", } assert.NoError(t, err) assert.Equal(t, expected, output)