Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Add new tokens command for managing API tokens #170

Merged
merged 8 commits into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fixup! Add new tokens command for managing API tokens
  • Loading branch information
cmoog committed Nov 3, 2020
commit 9f4e472fdd9d4ce4d300835560e035d56372aade
5 changes: 5 additions & 0 deletions docs/coder_tokens.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

manage Coder API tokens for the active user

### Synopsis

Create and manage API Tokens for authenticating the CLI.
Statically authenticate using the token value with the `CODER_TOKEN` and `CODER_URL` environment variables.

### Options

```
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ var verbose bool = false
// Make constructs the "coder" root command
func Make() *cobra.Command {
app := &cobra.Command{
Use: "coder",
Short: "coder provides a CLI for working with an existing Coder Enterprise installation",
Use: "coder",
Short: "coder provides a CLI for working with an existing Coder Enterprise installation",
SilenceErrors: true,
SilenceUsage: true,
DisableAutoGenTag: true,
Expand Down
16 changes: 8 additions & 8 deletions internal/cmd/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import (

func tokensCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "tokens",
Use: "tokens",
Short: "manage Coder API tokens for the active user",
Long: "Create and manage API Tokens for authenticating the CLI.\n" +
"Statically authenticate using the token value with the " + "`" + "CODER_TOKEN" + "`" + " and " + "`" + "CODER_URL" + "`" + " environment variables.",
}
cmd.AddCommand(
lsTokensCmd(),
Expand All @@ -38,9 +40,7 @@ func lsTokensCmd() *cobra.Command {
return err
}

err = tablewriter.WriteTable(len(tokens), func(i int) interface{} {
return tokens[i]
})
err = tablewriter.WriteTable(len(tokens), func(i int) interface{} { return tokens[i] })
if err != nil {
return err
}
Expand Down Expand Up @@ -75,9 +75,9 @@ func createTokensCmd() *cobra.Command {

func rmTokenCmd() *cobra.Command {
return &cobra.Command{
Use: "rm [token_id]",
Use: "rm [token_id]",
Short: "remove an API token by its unique ID",
Args: cobra.ExactArgs(1),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
client, err := newClient(ctx)
Expand All @@ -94,9 +94,9 @@ func rmTokenCmd() *cobra.Command {

func regenTokenCmd() *cobra.Command {
return &cobra.Command{
Use: "regen [token_id]",
Use: "regen [token_id]",
Short: "regenerate an API token by its unique ID and print the new token to stdout",
Args: cobra.ExactArgs(1),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
client, err := newClient(ctx)
Expand Down