Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions pkg/cmd/apitoken/apitoken.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package apitoken

import (
"fmt"

"github.com/depot/cli/pkg/config"
"github.com/spf13/cobra"
)

func NewCmdApiToken() *cobra.Command {
cmd := &cobra.Command{
Use: "api-token",
Short: "Get the API token for a Depot login",
RunE: func(cmd *cobra.Command, args []string) error {
token := config.GetApiToken()
if token == "" {
return fmt.Errorf("missing API token, please run `depot login`")
}

fmt.Println(token)
return nil
},
}
return cmd
}
2 changes: 2 additions & 0 deletions pkg/cmd/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/spf13/cobra"

apiTokenCmd "github.com/depot/cli/pkg/cmd/apitoken"
bakeCmd "github.com/depot/cli/pkg/cmd/bake"
"github.com/depot/cli/pkg/cmd/blog"
buildCmd "github.com/depot/cli/pkg/cmd/build"
Expand Down Expand Up @@ -62,6 +63,7 @@ func NewCmdRoot(version, buildDate string) *cobra.Command {
_ = cmd.PersistentFlags().MarkHidden("config")

// Child commands
cmd.AddCommand(apiTokenCmd.NewCmdApiToken())
cmd.AddCommand(bakeCmd.NewCmdBake())
cmd.AddCommand(blog.NewCmdBlog())
cmd.AddCommand(buildCmd.NewCmdBuild())
Expand Down
Loading