feat(aliases): add aliases for apikeys command

- `apikey`, `api` are aliases for `apikeys` command
- `ls`, `show` are aliases for `list` subcommand
- `c`, `new` are aliases for `create` subcommand
- `revoke`, `exp`, `e` are aliases for the `expire` subcommand
This commit is contained in:
zakaria 2022-03-02 15:31:11 +10:00
parent 5310f8692b
commit 052dbfe440

View file

@ -36,13 +36,15 @@ func init() {
} }
var apiKeysCmd = &cobra.Command{ var apiKeysCmd = &cobra.Command{
Use: "apikeys", Use: "apikeys",
Short: "Handle the Api keys in Headscale", Short: "Handle the Api keys in Headscale",
Aliases: []string{"apikey", "api"},
} }
var listAPIKeys = &cobra.Command{ var listAPIKeys = &cobra.Command{
Use: "list", Use: "list",
Short: "List the Api keys for headscale", Short: "List the Api keys for headscale",
Aliases: []string{"ls", "show"},
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
output, _ := cmd.Flags().GetString("output") output, _ := cmd.Flags().GetString("output")
@ -107,6 +109,7 @@ var createAPIKeyCmd = &cobra.Command{
Creates a new Api key, the Api key is only visible on creation Creates a new Api key, the Api key is only visible on creation
and cannot be retrieved again. and cannot be retrieved again.
If you loose a key, create a new one and revoke (expire) the old one.`, If you loose a key, create a new one and revoke (expire) the old one.`,
Aliases: []string{"c", "new"},
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
output, _ := cmd.Flags().GetString("output") output, _ := cmd.Flags().GetString("output")
@ -144,7 +147,7 @@ If you loose a key, create a new one and revoke (expire) the old one.`,
var expireAPIKeyCmd = &cobra.Command{ var expireAPIKeyCmd = &cobra.Command{
Use: "expire", Use: "expire",
Short: "Expire an ApiKey", Short: "Expire an ApiKey",
Aliases: []string{"revoke"}, Aliases: []string{"revoke", "exp", "e"},
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
output, _ := cmd.Flags().GetString("output") output, _ := cmd.Flags().GetString("output")