Skip to content

Commit

Permalink
Improve help text for all commands (#145)
Browse files Browse the repository at this point in the history
* Improve help text for all commands

* 0.23.1
  • Loading branch information
baksetercx authored Dec 19, 2024
1 parent e311b4e commit 4463c67
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 48 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.23.0
0.23.1
9 changes: 5 additions & 4 deletions pkg/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ import (
const commandName = "build"

var Command *cli.Command = &cli.Command{
Name: commandName,
Aliases: []string{"b"},
Usage: "Build a Docker image from a project file.",
Name: commandName,
Aliases: []string{"b"},
Usage: "Build a Docker image from a project file.",
UsageText: "3lv build [options] <application-name>",
Flags: []cli.Flag{
shared.ProjectFileFlag(),
shared.SystemNameFlag(
Expand Down Expand Up @@ -105,7 +106,7 @@ var Command *cli.Command = &cli.Command{

func Build(ctx context.Context, c *cli.Command) error {
if c.NArg() <= 0 {
return cli.ShowAppHelp(c)
cli.ShowSubcommandHelpAndExit(c, 1)
}

// Required args
Expand Down
13 changes: 7 additions & 6 deletions pkg/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ var (
)

var Command *cli.Command = &cli.Command{
Name: commandName,
Aliases: []string{"c"},
Usage: "Create a new project",
Name: commandName,
Aliases: []string{"c"},
Usage: "Create a new project from one of Elvia's templates.",
UsageText: "3lv create [options] <output-directory>",
Flags: []cli.Flag{
shared.SystemNameFlag(
"The name of your system (Kubernetes namespace) you want to create your application in.",
Expand Down Expand Up @@ -91,11 +92,9 @@ var Command *cli.Command = &cli.Command{

func Create(ctx context.Context, c *cli.Command) error {
if c.NArg() <= 0 {
return cli.ShowAppHelp(c)
cli.ShowSubcommandHelpAndExit(c, 1)
}

nonInteractive := c.Bool("non-interactive")

outputDirectory := c.Args().First()
if outputDirectory == "" {
return cli.Exit("Output directory not provided", 1)
Expand All @@ -118,7 +117,9 @@ func Create(ctx context.Context, c *cli.Command) error {
}
return *parsed
}()

defaultBranch := c.String("default-branch")
nonInteractive := c.Bool("non-interactive")

checkCoooiecutterInstalledOutput := checkCookiecutterInstalledCommand(nil)
if command.IsError(checkCoooiecutterInstalledOutput) {
Expand Down
18 changes: 9 additions & 9 deletions pkg/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ import (
)

var Command *cli.Command = &cli.Command{
Name: "deploy",
Aliases: []string{"d"},
Usage: "Deploy an application to a Kubernetes cluster",
Hidden: true,
Name: "deploy",
Aliases: []string{"d"},
Usage: "Deploy an application to a one of Atlas' Kubernetes clusters.",
UsageText: "3lv deploy [options] <application-name>",
Hidden: true,
Flags: []cli.Flag{
shared.SystemNameFlag(
"The name of the system (Kubernetes namespace) to deploy to.",
Expand All @@ -28,10 +29,9 @@ var Command *cli.Command = &cli.Command{
shared.RuntimeCloudProviderFlag(),
shared.HelmValuesFileFlag(),
&cli.StringFlag{
Name: "image-tag",
Aliases: []string{"i"},
Usage: "The image tag to deploy.",
Required: true,
Name: "image-tag",
Aliases: []string{"i"},
Usage: "The image tag to deploy.",
},
&cli.StringFlag{
Name: "environment",
Expand Down Expand Up @@ -159,7 +159,7 @@ var Command *cli.Command = &cli.Command{

func Deploy(ctx context.Context, c *cli.Command) error {
if c.NArg() <= 0 {
return cli.ShowAppHelp(c)
cli.ShowSubcommandHelpAndExit(c, 1)
}

if !c.Bool("allow-deploy") {
Expand Down
22 changes: 18 additions & 4 deletions pkg/githubactions/githubactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ const (
var helmValuesFileTemplate embed.FS

var Command *cli.Command = &cli.Command{
Name: commandName,
Aliases: []string{"gha"},
Usage: "Add GitHub Actions to a project",
Name: commandName,
Aliases: []string{"gha"},
Usage: "Add build and deploy with GitHub Actions to an exisiting project.",
UsageText: "3lv build [options] <project-directory>",
Flags: []cli.Flag{
shared.SystemNameFlag(
"The name of your system (Kubernetes namespace) you want to deploy to.",
Expand All @@ -51,8 +52,21 @@ var Command *cli.Command = &cli.Command{
}

func GitHubActions(ctx context.Context, c *cli.Command) error {
if c.NArg() <= 0 {
cli.ShowSubcommandHelpAndExit(c, 1)
}

projectDirectory := func() string {
first := c.Args().First()
if first == "" {
return "."
}

return first
}()

err := CreateDeployWorkflow(
".",
projectDirectory,
c.String("project-file"),
c.String("runtime-cloud-provider"),
c.String("system-name"),
Expand Down
9 changes: 5 additions & 4 deletions pkg/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ const commandName = "run"
var composeTemplates embed.FS

var Command *cli.Command = &cli.Command{
Name: commandName,
Aliases: []string{"r"},
Usage: "Run your application with Docker Compose",
Name: commandName,
Aliases: []string{"r"},
Usage: "Run your application with Docker Compose.",
UsageText: "3lv run [options] <application-name>",
Flags: []cli.Flag{
shared.SystemNameFlag(
"The name of your system.",
Expand All @@ -39,7 +40,7 @@ var Command *cli.Command = &cli.Command{

func Run(ctx context.Context, c *cli.Command) error {
if c.NArg() <= 0 {
return cli.ShowAppHelp(c)
cli.ShowSubcommandHelpAndExit(c, 1)
}

applicationName := c.Args().First()
Expand Down
9 changes: 5 additions & 4 deletions pkg/scan/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ import (
)

var Command *cli.Command = &cli.Command{
Name: "scan",
Aliases: []string{"s"},
Usage: "Scan image using Trivy.",
Name: "scan",
Aliases: []string{"s"},
Usage: "Scan a container image using Trivy.",
UsageText: "3lv scan [options] <image-name>",
Flags: []cli.Flag{
shared.SeverityFlag("severity"),
shared.FormatsFlag("formats"),
Expand All @@ -29,7 +30,7 @@ var Command *cli.Command = &cli.Command{

func Scan(ctx context.Context, c *cli.Command) error {
if c.NArg() <= 0 {
return cli.ShowAppHelp(c)
cli.ShowSubcommandHelpAndExit(c, 1)
}

// Required args
Expand Down
23 changes: 10 additions & 13 deletions pkg/shared/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ func nameToEnvVar(name string) string {

func ProjectFileFlag() *cli.StringFlag {
return &cli.StringFlag{
Name: "project-file",
Aliases: []string{"f"},
Usage: "The project file to use. We currently support .NET (*.csproj), Go (go.mod) or a generic project (Dockerfile).",
Required: true,
Name: "project-file",
Aliases: []string{"f"},
Usage: "The project file to use. We currently support .NET (*.csproj), Go (go.mod) or a generic project (Dockerfile).",
}
}

Expand Down Expand Up @@ -47,20 +46,18 @@ func RuntimeCloudProviderFlag() *cli.StringFlag {

func SystemNameFlag(usage string, required bool) *cli.StringFlag {
return &cli.StringFlag{
Name: "system-name",
Aliases: []string{"s"},
Usage: usage,
Required: required,
Sources: cli.EnvVars("3LV_SYSTEM_NAME"),
Name: "system-name",
Aliases: []string{"s"},
Usage: usage,
Sources: cli.EnvVars("3LV_SYSTEM_NAME"),
}
}

func ApplicationNameFlag(usage string) *cli.StringFlag {
return &cli.StringFlag{
Name: "application-name",
Aliases: []string{"a"},
Usage: usage,
Required: true,
Name: "application-name",
Aliases: []string{"a"},
Usage: usage,
}
}

Expand Down
7 changes: 4 additions & 3 deletions pkg/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ const defaultInstallLocation = "/usr/local/bin"

func Command(version string) *cli.Command {
return &cli.Command{
Name: commandName,
Aliases: []string{"u"},
Usage: "Upgrade the Elvia CLI",
Name: commandName,
Aliases: []string{"u"},
Usage: "Upgrade the Elvia CLI to the latest version.",
UsageText: "3lv upgrade [options]",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "install-location",
Expand Down

0 comments on commit 4463c67

Please sign in to comment.