Skip to content

Commit

Permalink
Check error return for MarkFlagRequired
Browse files Browse the repository at this point in the history
  • Loading branch information
emily.johnson authored and sophiewigmore committed Mar 3, 2021
1 parent 99e97b2 commit 444379e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
10 changes: 8 additions & 2 deletions cargo/jam/commands/pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,14 @@ func pack() *cobra.Command {
cmd.Flags().BoolVar(&flags.offline, "offline", false, "enable offline caching of dependencies")
cmd.Flags().StringVar(&flags.stack, "stack", "", "restricts dependencies to given stack")

cmd.MarkFlagRequired("buildpack")
cmd.MarkFlagRequired("version")
err := cmd.MarkFlagRequired("buildpack")
if err != nil {
fmt.Fprintf(os.Stderr, "Unable to mark buildpack flag as required")
}
err = cmd.MarkFlagRequired("version")
if err != nil {
fmt.Fprintf(os.Stderr, "Unable to mark version flag as required")
}
return cmd
}

Expand Down
5 changes: 4 additions & 1 deletion cargo/jam/commands/summarize.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ func summarize() *cobra.Command {
cmd.Flags().StringVar(&flags.buildpackTarballPath, "buildpack", "", "path to a buildpackage tarball (required)")
cmd.Flags().StringVar(&flags.format, "format", "markdown", "format of output options are (markdown, json)")

cmd.MarkFlagRequired("buildpack")
err := cmd.MarkFlagRequired("buildpack")
if err != nil {
fmt.Fprintf(os.Stderr, "Unable to mark buildpack flag as required")
}
return cmd
}

Expand Down
6 changes: 5 additions & 1 deletion cargo/jam/commands/update_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"github.com/paketo-buildpacks/packit/cargo/jam/internal"
"github.com/spf13/cobra"
"os"
)

type updateBuilderFlags struct {
Expand All @@ -23,7 +24,10 @@ func updateBuilder() *cobra.Command {
cmd.Flags().StringVar(&flags.builderFile, "builder-file", "", "path to the builder.toml file (required)")
cmd.Flags().StringVar(&flags.lifecycleURI, "lifecycle-uri", "index.docker.io/buildpacksio/lifecycle", "URI for lifecycle image (optional: default=index.docker.io/buildpacksio/lifecycle)")

cmd.MarkFlagRequired("builder-file")
err := cmd.MarkFlagRequired("builder-file")
if err != nil {
fmt.Fprintf(os.Stderr, "Unable to mark builder-file flag as required")
}
return cmd
}

Expand Down
11 changes: 9 additions & 2 deletions cargo/jam/commands/update_buildpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"github.com/paketo-buildpacks/packit/cargo/jam/internal"
"github.com/spf13/cobra"
"os"
)

type updateBuildpackFlags struct {
Expand All @@ -23,8 +24,14 @@ func updateBuildpack() *cobra.Command {
cmd.Flags().StringVar(&flags.buildpackFile, "buildpack-file", "", "path to the buildpack.toml file (required)")
cmd.Flags().StringVar(&flags.packageFile, "package-file", "", "path to the package.toml file (required)")

cmd.MarkFlagRequired("buildpack-file")
cmd.MarkFlagRequired("package-file")
err := cmd.MarkFlagRequired("buildpack-file")
if err != nil {
fmt.Fprintf(os.Stderr, "Unable to mark buildpack-file flag as required")
}
err = cmd.MarkFlagRequired("package-file")
if err != nil {
fmt.Fprintf(os.Stderr, "Unable to mark package-file flag as required")
}
return cmd
}

Expand Down

0 comments on commit 444379e

Please sign in to comment.