Skip to content

Commit

Permalink
unify command usage texts about app identifiers and app directory (ex…
Browse files Browse the repository at this point in the history
…cept for download)
  • Loading branch information
jfeo committed Dec 6, 2024
1 parent dba8d60 commit 12ecdce
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 37 deletions.
16 changes: 7 additions & 9 deletions cmd/app/share/cmd.go
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
package share

import (
"fmt"
"net/http"

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

var long string = `Creates a shared URL for the specified app.
const longFormat string = `Creates a shared URL for the specified app.
If <name> and <organization> flags are set, they define the app
to create a shared URL for.
If they are not, the default deployment section in the manifest is used,
if it is defined.
%s
If [app directory] is specified, that directory will be used to read the
app manifest for the default deployment information.
If no [app directory] is specified, the current working directory is used.
%s
`

var long string = fmt.Sprintf(longFormat, usage.AppIdentifier("to create a shared URL for"), usage.AppDirectoryArgument)

var Cmd = &cobra.Command{
Use: "share [app directory]",
RunE: run,
Expand Down
16 changes: 7 additions & 9 deletions cmd/app/unshare/cmd.go
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
package unshare

import (
"fmt"
"net/http"

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

var long string = `Removes a shared URL for the specified app.
const longFormat string = `Removes a shared URL for the specified app.
If <name> and <organization> flags are set, they define the app
to remove a shared URL for.
If they are not, the default deployment section in the manifest is used,
if it is defined.
%s
If [app directory] is specified, that directory will be used to read the
app manifest for the default deployment information.
If no [app directory] is specified, the current working directory is used.
%s
`

var long string = fmt.Sprintf(longFormat, usage.AppIdentifier("to remove a shared URL for"), usage.AppDirectoryArgument)

var Cmd = &cobra.Command{
Use: "unshare [app directory]",
RunE: run,
Expand Down
14 changes: 7 additions & 7 deletions cmd/deletecmd/cmd.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package deletecmd

import (
"fmt"
"net/http"

"numerous.com/cli/cmd/args"
"numerous.com/cli/cmd/errorhandling"
"numerous.com/cli/cmd/group"
"numerous.com/cli/cmd/output"
"numerous.com/cli/cmd/usage"
"numerous.com/cli/internal/app"
"numerous.com/cli/internal/dir"
"numerous.com/cli/internal/gql"
Expand All @@ -24,16 +26,14 @@ var Cmd = &cobra.Command{
Args: args.OptionalAppDir(&appDir),
}

const long = `Deletes the specified app from the organization.
const longFormat = `Deletes the specified app from the organization.
If <app> and <organization> flags are set, they define the app to delete. If
they are not the default deployment section in the manifest is used if it is
defined.
%s
If [app directory] is specified, that directory will be used to read the
app manifest for the default deployment information.
%s
`

If no [app directory] is specified, the current working directory is used.`
var long string = fmt.Sprintf(longFormat, usage.AppIdentifier("to delete"), usage.AppDirectoryArgument)

const example = `To delete an app use the following form:
Expand Down
27 changes: 15 additions & 12 deletions cmd/deploy/cmd.go
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
package deploy

import (
"fmt"
"net/http"

"numerous.com/cli/cmd/args"
"numerous.com/cli/cmd/errorhandling"
"numerous.com/cli/cmd/group"
"numerous.com/cli/cmd/usage"
"numerous.com/cli/internal/app"
"numerous.com/cli/internal/gql"

"github.com/spf13/cobra"
)

const longFormat string = `Deploys an application to an organization on the Numerous platform.
After deployment the deployed version of the app is available in the
organization's apps page.
%s
%s
`

var long string = fmt.Sprintf(longFormat, usage.AppIdentifier("to deploy"), usage.AppDirectoryArgument)

var Cmd = &cobra.Command{
Use: "deploy [app directory]",
RunE: run,
GroupID: group.AppCommandsGroupID,
Short: "Deploy an app to an organization",
Long: `Deploys an application to an organization on the Numerous platform.
An app's deployment is identified with the <name> and <organization> identifier.
Deploying an app to a given <name> and <organization> combination, will override
the existing version.
The <name> must contain only lower-case alphanumeric characters and dashes.
After deployment the deployed version of the app is available in the
organization's apps page.
If no [app directory] is specified, the current working directory is used.`,
Long: long,
Example: `
If an app has been initialized in the current working directory, and it should
be pushed to the organization "organization-slug-a2ecf59b", and the app slug
Expand Down
6 changes: 6 additions & 0 deletions cmd/usage/app_directory_arg.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package usage

const AppDirectoryArgument string = `If [app directory] is specified, that directory will be used to read the
app manifest for the default deployment information.
If no [app directory] is specified, the current working directory is used.`
18 changes: 18 additions & 0 deletions cmd/usage/app_identifier.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package usage

import "fmt"

const appIdentifierFormat string = `The app %s is specified firstly by --app and
--organization flags, secondly by the deployment section in the manifest
(numerous.toml), and finally by the local configuration (see "numerous config").
If no app is identified either by --app or by the default deployment section in
the manifest, the app name in the manifest is converted into a slug, e.g.
"My Awesome App" would become "my-awesome-app".
App and organization identifiers must contain only lower-case alphanumeric
characters and dashes.`

func AppIdentifier(action string) string {
return fmt.Sprintf(appIdentifierFormat, action)
}

0 comments on commit 12ecdce

Please sign in to comment.