Skip to content

Commit

Permalink
Clean up CLI help
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobwgillespie committed Mar 24, 2022
1 parent ee0ccf9 commit 56fc33a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/cmd/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewCmdBuild() *cobra.Command {

cmd := &cobra.Command{
Use: "build [OPTIONS] PATH | URL | -",
Short: "run a Docker build on Depot",
Short: "Run a Docker build on Depot",
Args: cli.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
if options.project == "" {
Expand Down
17 changes: 13 additions & 4 deletions pkg/cmd/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ func NewCmdInit() *cobra.Command {
var projectID string

cmd := &cobra.Command{
Use: "init [flags] [<dir>]",
Hidden: true,
Args: cli.RequiresMaxArgs(1),
Use: "init [flags] [<dir>]",
Short: "Create a `depot.json` project config",
Args: cli.RequiresMaxArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
force, _ := cmd.Flags().GetBool("force")
context := "."
Expand All @@ -39,7 +39,16 @@ func NewCmdInit() *cobra.Command {
return fmt.Errorf("Project configuration %s already exists at path \"%s\", re-run with `--force` to overwrite", filepath.Base(existingFile), context)
}

client, err := api.NewDepotFromEnv(config.GetApiToken())
// TODO: make this a helper
token := os.Getenv("DEPOT_TOKEN")
if token == "" {
token = config.GetApiToken()
}
if token == "" {
return fmt.Errorf("missing API token, please run `depot login`")
}

client, err := api.NewDepotFromEnv(token)
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/cmd/login/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import (

func NewCmdLogin() *cobra.Command {
cmd := &cobra.Command{
Use: "login",
Use: "login",
Short: "Authenticate the Depot CLI",
RunE: func(cmd *cobra.Command, args []string) error {
clear, _ := cmd.Flags().GetBool("clear")

Expand Down

0 comments on commit 56fc33a

Please sign in to comment.