-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #529 from rsteube/glab-new-commands
glab: new commands from 1.19.0
- Loading branch information
Showing
8 changed files
with
178 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package action | ||
|
||
import ( | ||
"strconv" | ||
|
||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
type sshKey struct { | ||
Id int | ||
Title string | ||
} | ||
|
||
func ActionSshKeyIds(cmd *cobra.Command) carapace.Action { | ||
return carapace.ActionCallback(func(c carapace.Context) carapace.Action { | ||
var queryResult []sshKey | ||
return actionApi(cmd, "/user/keys", &queryResult, func() carapace.Action { | ||
vals := make([]string, 0, len(queryResult)*2) | ||
for _, sshKey := range queryResult { | ||
vals = append(vals, strconv.Itoa(sshKey.Id), sshKey.Title) | ||
} | ||
return carapace.ActionValuesDescribed(vals...) | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/completers/glab_completer/cmd/action" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var repo_viewCmd = &cobra.Command{ | ||
Use: "view [repository] [flags]", | ||
Short: "View a project/repository", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(repo_viewCmd).Standalone() | ||
repo_viewCmd.Flags().StringP("branch", "b", "", "View a specific branch of the repository") | ||
repo_viewCmd.Flags().BoolP("web", "w", false, "Open a project in the browser") | ||
|
||
repoCmd.AddCommand(repo_viewCmd) | ||
|
||
carapace.Gen(repo_viewCmd).FlagCompletion(carapace.ActionMap{ | ||
"branch": carapace.ActionCallback(func(c carapace.Context) carapace.Action { | ||
if len(c.Args) > 0 { | ||
action.FakeRepoFlag(repo_viewCmd, c.Args[0]) | ||
return action.ActionBranches(repo_viewCmd) | ||
} | ||
return carapace.ActionValues() | ||
}), | ||
}) | ||
|
||
carapace.Gen(repo_viewCmd).PositionalCompletion( | ||
action.ActionRepo(repo_viewCmd), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var sshKeyCmd = &cobra.Command{ | ||
Use: "ssh-key <command>", | ||
Short: "Manage SSH keys", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(sshKeyCmd).Standalone() | ||
|
||
rootCmd.AddCommand(sshKeyCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var sshKey_addCmd = &cobra.Command{ | ||
Use: "add", | ||
Short: "Add an SSH key to your GitLab account", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(sshKey_addCmd).Standalone() | ||
sshKey_addCmd.Flags().StringP("expires-at", "e", "", "The expiration date of the SSH key in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)") | ||
sshKey_addCmd.Flags().StringP("title", "t", "", "New SSH key's title") | ||
|
||
sshKeyCmd.AddCommand(sshKey_addCmd) | ||
|
||
carapace.Gen(sshKey_addCmd).PositionalCompletion( | ||
carapace.ActionFiles(), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/completers/glab_completer/cmd/action" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var sshKey_getCmd = &cobra.Command{ | ||
Use: "get <key-id>", | ||
Short: "Gets a single key", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(sshKey_getCmd).Standalone() | ||
|
||
sshKeyCmd.AddCommand(sshKey_getCmd) | ||
|
||
carapace.Gen(sshKey_getCmd).PositionalCompletion( | ||
action.ActionSshKeyIds(sshKeyCmd), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var sshKey_listCmd = &cobra.Command{ | ||
Use: "list", | ||
Short: "Lists currently authenticated user’s SSH keys", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(sshKey_listCmd).Standalone() | ||
sshKey_listCmd.Flags().BoolP("show-id", "", false, "Show IDs of SSH Keys") | ||
|
||
sshKeyCmd.AddCommand(sshKey_listCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/completers/glab_completer/cmd/action" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var variable_listCmd = &cobra.Command{ | ||
Use: "list", | ||
Short: "List project or group variables", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(variable_listCmd).Standalone() | ||
variable_listCmd.Flags().StringP("group", "g", "", "List group variables") | ||
|
||
variableCmd.AddCommand(variable_listCmd) | ||
|
||
carapace.Gen(variable_listCmd).FlagCompletion(carapace.ActionMap{ | ||
"group": action.ActionGroups(variable_listCmd), | ||
}) | ||
} |