()
| 16 | ) |
| 17 | |
| 18 | func (r *RootCmd) tokens() *serpent.Command { |
| 19 | cmd := &serpent.Command{ |
| 20 | Use: "tokens", |
| 21 | Short: "Manage personal access tokens", |
| 22 | Long: "Tokens are used to authenticate automated clients to Coder.\n" + FormatExamples( |
| 23 | Example{ |
| 24 | Description: "Create a token for automation", |
| 25 | Command: "coder tokens create", |
| 26 | }, |
| 27 | Example{ |
| 28 | Description: "List your tokens", |
| 29 | Command: "coder tokens ls", |
| 30 | }, |
| 31 | Example{ |
| 32 | Description: "Create a scoped token", |
| 33 | Command: "coder tokens create --scope workspace:read --allow workspace:<uuid>", |
| 34 | }, |
| 35 | Example{ |
| 36 | Description: "Remove a token by ID", |
| 37 | Command: "coder tokens rm WuoWs4ZsMX", |
| 38 | }, |
| 39 | ), |
| 40 | Aliases: []string{"token"}, |
| 41 | Handler: func(inv *serpent.Invocation) error { |
| 42 | return inv.Command.HelpHandler(inv) |
| 43 | }, |
| 44 | Children: []*serpent.Command{ |
| 45 | r.createToken(), |
| 46 | r.listTokens(), |
| 47 | r.viewToken(), |
| 48 | r.removeToken(), |
| 49 | }, |
| 50 | } |
| 51 | return cmd |
| 52 | } |
| 53 | |
| 54 | func (r *RootCmd) createToken() *serpent.Command { |
| 55 | var ( |
no test coverage detected