Skip to content

Commit 64fc965

Browse files
committed
add command to get current session token (#2801)
1 parent b1e4cfe commit 64fc965

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

cli/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ func Root() *cobra.Command {
130130
state(),
131131
stop(),
132132
templates(),
133+
token(),
133134
update(),
134135
users(),
135136
versionCmd(),

cli/token.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package cli
2+
3+
import (
4+
"fmt"
5+
"strings"
6+
7+
"github.com/spf13/cobra"
8+
9+
"github.com/coder/coder/cli/cliui"
10+
)
11+
12+
func token() *cobra.Command {
13+
return &cobra.Command{
14+
Use: "token",
15+
RunE: func(cmd *cobra.Command, args []string) error {
16+
client, err := createClient(cmd)
17+
if err != nil {
18+
return err
19+
}
20+
21+
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Session token is %s\n", cliui.Styles.Code.Render(strings.TrimSpace(client.SessionToken)))
22+
return nil
23+
},
24+
}
25+
}

0 commit comments

Comments
 (0)