Skip to content

Commit

Permalink
Cleanup up CLI command help
Browse files Browse the repository at this point in the history
  • Loading branch information
akclace committed Feb 8, 2024
1 parent 1846b9d commit 649d182
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 47 deletions.
34 changes: 12 additions & 22 deletions cmd/clace/app_cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ const (
DRY_RUN_FLAG = "dry-run"
DRY_RUN_ARG = "dryRun"
DRY_RUN_MESSAGE = "\n*** dry-run mode, changes have NOT been committed. ***\n"
PATH_SPEC_HELP = `The domain and path are separated by a ":". pathSpec supports a glob pattern.
In the glob, * matches any number of characters, ** matches any number of characters including /.
all is a shortcut for "*:**", which matches all apps across all domains, including no domain.
To prevent shell expansion for *, placing the path in quotes is recommended.
`
)

func initAppCommand(commonFlags []cli.Flag, clientConfig *utils.ClientConfig) *cli.Command {
Expand Down Expand Up @@ -139,11 +144,9 @@ func appListCommand(commonFlags []cli.Flag, clientConfig *utils.ClientConfig) *c
ArgsUsage: "<pathSpec>",
UsageText: `args: <pathSpec>
<pathSpec> defaults to "*:**" (same as "all", without quotes) for the list command, which matches all apps across all domains, including no domain.
The domain and path are separated by a ":". pathSpec supports a glob pattern.
In the glob, * matches any number of characters, ** matches any number of characters including /.
To prevent shell expansion for *, placing the path in quotes is recommended.
<pathSpec> defaults to "*:**" (same as "all") for the list command.
` + PATH_SPEC_HELP +
`
Examples:
List all apps, across domains: clace app list
List apps at the lop level with no domain specified: clace app list "*"
Expand Down Expand Up @@ -266,10 +269,7 @@ func appDeleteCommand(commonFlags []cli.Flag, clientConfig *utils.ClientConfig)

UsageText: `args: <pathSpec>
<pathSpec> is a required argument. The domain and path are separated by a ":". pathSpec supports a glob pattern.
In the glob, * matches any number of characters, ** matches any number of characters including /.
all is a shortcut for "*:**", which matches all apps across all domains, including no domain.
To prevent shell expansion for *, placing the path in quotes is recommended.
<pathSpec> is a required argument. ` + PATH_SPEC_HELP + `
Examples:
Delete all apps, across domains, in dry-run mode: clace app delete --dry-run all
Expand Down Expand Up @@ -318,10 +318,7 @@ func appApproveCommand(commonFlags []cli.Flag, clientConfig *utils.ClientConfig)

UsageText: `args: <pathSpec>
<pathSpec> is a required argument. The domain and path are separated by a ":". pathSpec supports a glob pattern.
In the glob, * matches any number of characters, ** matches any number of characters including /.
all is a shortcut for "*:**", which matches all apps across all domains, including no domain.
To prevent shell expansion for *, placing the path in quotes is recommended.
<pathSpec> is a required argument. ` + PATH_SPEC_HELP + `
Examples:
Approve all apps, across domains: clace app approve all
Expand Down Expand Up @@ -384,11 +381,7 @@ func appReloadCommand(commonFlags []cli.Flag, clientConfig *utils.ClientConfig)

UsageText: `args: <pathSpec>
<pathSpec> is a required argument. The domain and path are separated by a ":". pathSpec supports a glob pattern.
In the glob, * matches any number of characters, ** matches any number of characters including /.
all is a shortcut for "*:**", which matches all apps across all domains, including no domain.
To prevent shell expansion for *, placing the path in quotes is recommended.
<pathSpec> is a required argument. ` + PATH_SPEC_HELP + `
Dev apps are reloaded from disk. For prod apps, the stage app is reloaded from git (or from local disk if git is not used).
If --approve option is specified, the app permissions are audited and approved. If --approve is not specified and the app needs additional
permissions, the reload will fail. If --promote is specified, the stage app is promoted to prod after reload. If --promote is not specified,
Expand Down Expand Up @@ -483,10 +476,7 @@ func appPromoteCommand(commonFlags []cli.Flag, clientConfig *utils.ClientConfig)
ArgsUsage: "<pathSpec>",
UsageText: `args: <pathSpec>
<pathSpec> is a required argument. The domain and path are separated by a ":". pathSpec supports a glob pattern.
In the glob, * matches any number of characters, ** matches any number of characters including /.
all is a shortcut for "*:**", which matches all apps across all domains, including no domain.
To prevent shell expansion for *, placing the path in quotes is recommended.
<pathSpec> is a required argument. ` + PATH_SPEC_HELP + `
Examples:
Promote all apps, across domains: clace app promote all
Expand Down
33 changes: 9 additions & 24 deletions cmd/clace/app_updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ func appUpdateStageWrite(commonFlags []cli.Flag, clientConfig *utils.ClientConfi

UsageText: `args: <pathSpec> <value:true|false>
First required argument is <pathSpec>. The domain and path are separated by a ":". pathSpec supports a glob pattern.
In the glob, * matches any number of characters, ** matches any number of characters including /.
all is a shortcut for "*:**", which matches all apps across all domains, including no domain.
To prevent shell expansion for *, placing the path in quotes is recommended.
First required argument is <pathSpec>. ` + PATH_SPEC_HELP + `
The second required argument <value> is a boolean value, true or false.
Examples:
Expand Down Expand Up @@ -106,11 +102,7 @@ func appUpdatePreviewWrite(commonFlags []cli.Flag, clientConfig *utils.ClientCon

UsageText: `args: <pathSpec> <value:true|false>
First required argument is <pathSpec>. The domain and path are separated by a ":". pathSpec supports a glob pattern.
In the glob, * matches any number of characters, ** matches any number of characters including /.
all is a shortcut for "*:**", which matches all apps across all domains, including no domain.
To prevent shell expansion for *, placing the path in quotes is recommended.
First required argument is <pathSpec>. ` + PATH_SPEC_HELP + `
The second required argument <value> is a boolean value, true or false.
Examples:
Expand Down Expand Up @@ -172,12 +164,8 @@ func appUpdateAuthnType(commonFlags []cli.Flag, clientConfig *utils.ClientConfig

UsageText: `args: <pathSpec> <value:default|none>
First required argument is <pathSpec>. The domain and path are separated by a ":". pathSpec supports a glob pattern.
In the glob, * matches any number of characters, ** matches any number of characters including /.
all is a shortcut for "*:**", which matches all apps across all domains, including no domain.
To prevent shell expansion for *, placing the path in quotes is recommended.
The second required argument <value> is a string, default or none.
First required argument is <pathSpec>. ` + PATH_SPEC_HELP + `
The second required argument <value> is a string, default or none.
Examples:
Update all apps, across domains: clace app update auth-type all default
Expand Down Expand Up @@ -227,22 +215,19 @@ func appUpdateGitAuth(commonFlags []cli.Flag, clientConfig *utils.ClientConfig)
Before: altsrc.InitInputSourceWithContext(flags, altsrc.NewTomlSourceFromFlagFunc(configFileFlagName)),
ArgsUsage: "<pathSpec> <value>",

UsageText: `args: <pathSpec> <value:default|none>
First required argument is <pathSpec>. The domain and path are separated by a ":". pathSpec supports a glob pattern.
In the glob, * matches any number of characters, ** matches any number of characters including /.
all is a shortcut for "*:**", which matches all apps across all domains, including no domain.
To prevent shell expansion for *, placing the path in quotes is recommended.
UsageText: `args: <pathSpec> <entryName>
The second required argument <value> is a string. Specify the git_auth entry key name as configured in the clace.toml config.
First required argument is <pathSpec>. ` + PATH_SPEC_HELP + `
The second required argument <entryName> is a string. Specify the git_auth entry key name as configured in the clace.toml config.
Set to "-" to remove the git_auth entry.
Examples:
Update all apps, across domains: clace app update git-auth all mygit
Update apps in the example.com domain: clace app git-auth "example.com:**" gitentrykey`,

Action: func(cCtx *cli.Context) error {
if cCtx.NArg() != 2 {
return fmt.Errorf("requires two argument: <pathSpec> <value>")
return fmt.Errorf("requires two argument: <pathSpec> <entryName>")
}

client := utils.NewHttpClient(clientConfig.ServerUri, clientConfig.AdminUser, clientConfig.AdminPassword, clientConfig.SkipCertCheck)
Expand Down
6 changes: 5 additions & 1 deletion internal/server/app_updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,11 @@ func (s *Server) updateAppSettings(ctx context.Context, tx metadata.Transaction,
}

if updateAppRequest.GitAuthName != utils.StringValueUndefined {
linkedApp.Settings.GitAuthName = string(updateAppRequest.GitAuthName)
if updateAppRequest.GitAuthName == "-" {
linkedApp.Settings.GitAuthName = ""
} else {
linkedApp.Settings.GitAuthName = string(updateAppRequest.GitAuthName)
}
}

if err := s.db.UpdateAppSettings(ctx, tx, linkedApp); err != nil {
Expand Down

0 comments on commit 649d182

Please sign in to comment.