Skip to content

Commit

Permalink
app list: use configured organization and fix organization flag usage…
Browse files Browse the repository at this point in the history
… text
  • Loading branch information
jfeo committed Dec 10, 2024
1 parent ca49f84 commit 1b4cc57
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
16 changes: 12 additions & 4 deletions cmd/app/list/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"net/http"

"github.com/spf13/cobra"
"numerous.com/cli/cmd/args"
"numerous.com/cli/cmd/errorhandling"
"numerous.com/cli/cmd/output"
"numerous.com/cli/internal/app"
"numerous.com/cli/internal/config"
"numerous.com/cli/internal/gql"
)

Expand All @@ -20,8 +20,16 @@ var Cmd = &cobra.Command{
}

func run(cmd *cobra.Command) error {
if cmdArgs.organizationSlug == "" {
output.PrintError("Missing organization argument.", "")
orgSlug := cmdArgs.organizationSlug
if orgSlug == "" {
orgSlug = config.OrganizationSlug()
}

if orgSlug == "" {
output.PrintError(
"No organization provided or configured",
"Specify an organization with the --organization flag, or configure one with \"numerous config\".",
)
cmd.Usage() // nolint:errcheck

return errorhandling.ErrAlreadyPrinted
Expand All @@ -35,5 +43,5 @@ func run(cmd *cobra.Command) error {

func init() {
flags := Cmd.Flags()
args.AddOrganizationSlugFlag(flags, "to list apps from", &cmdArgs.organizationSlug)
flags.StringVarP(&cmdArgs.organizationSlug, "organization", "o", "", "The organization slug identifier to list apps from. List available organizations with 'numerous organization list'.")
}
6 changes: 1 addition & 5 deletions cmd/args/appident.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ type AppIdentifierArg struct {
}

func (a *AppIdentifierArg) AddAppIdentifierFlags(flags *pflag.FlagSet, action string) {
AddOrganizationSlugFlag(flags, action, &a.OrganizationSlug)
flags.StringVarP(&a.OrganizationSlug, "organization", "o", "", "The organization slug identifier of the app "+action+". List available organizations with 'numerous organization list'.")
flags.StringVarP(&a.AppSlug, "app", "a", "", "An app slug identifier of the app "+action+".")
}

func AddOrganizationSlugFlag(flags *pflag.FlagSet, action string, orgSlug *string) {
flags.StringVarP(orgSlug, "organization", "o", "", "The organization slug identifier of the app "+action+". List available organizations with 'numerous organization list'.")
}

0 comments on commit 1b4cc57

Please sign in to comment.