Skip to content

Commit

Permalink
Merge pull request #1061 from rsteube/gh-updates-from-2.9.0
Browse files Browse the repository at this point in the history
gh: updates from v2.9.0
  • Loading branch information
rsteube authored Apr 26, 2022
2 parents dcf1cfc + e759822 commit 9971593
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 6 deletions.
14 changes: 13 additions & 1 deletion completers/gh_completer/cmd/codespace_create.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package cmd

import (
"path/filepath"
"strings"

"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/completers/gh_completer/cmd/action"
"github.com/spf13/cobra"
Expand All @@ -16,15 +19,24 @@ func init() {
carapace.Gen(codespace_createCmd).Standalone()
codespace_createCmd.Flags().StringP("branch", "b", "", "repository branch")
codespace_createCmd.Flags().Bool("default-permissions", false, "do not prompt to accept additional permissions requested by the codespace")
codespace_createCmd.Flags().String("devcontainer-path", "", "path to the devcontainer.json file to use when creating codespace")
codespace_createCmd.Flags().Duration("idle-timeout", 0, "allowed inactivity before codespace is stopped, e.g. \"10m\", \"1h\"")
codespace_createCmd.Flags().StringP("location", "l", "", "location: {EastUs|SouthEastAsia|WestEurope|WestUs2} (determined automatically if not provided)")
codespace_createCmd.Flags().StringP("machine", "m", "", "hardware specifications for the VM")
codespace_createCmd.Flags().StringP("repo", "r", "", "repository name with owner: user/repo")
codespace_createCmd.Flags().BoolP("status", "s", false, "show status of post-create command and dotfiles")
codespaceCmd.AddCommand(codespace_createCmd)

// TODO devcontainer-path
carapace.Gen(codespace_createCmd).FlagCompletion(carapace.ActionMap{
"branch": action.ActionBranches(codespace_createCmd),
"branch": action.ActionBranches(codespace_createCmd),
"devcontainer-path": carapace.ActionCallback(func(c carapace.Context) carapace.Action {
path := filepath.Dir(c.CallbackValue)
path = strings.TrimPrefix(path, "/")
return carapace.ActionMultiParts("/", func(c carapace.Context) carapace.Action {
return action.ActionContents(codespace_createCmd, path, codespace_createCmd.Flag("branch").Value.String())
})
}),
"location": carapace.ActionValues("EastUs", "SouthEastAsia", "WestEurope", "WestUs2"),
"machine": action.ActionCodespaceMachines(),
"repo": action.ActionOwnerRepositories(codespace_createCmd),
Expand Down
23 changes: 23 additions & 0 deletions completers/gh_completer/cmd/label_clone.go
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/gh_completer/cmd/action"
"github.com/spf13/cobra"
)

var label_cloneCmd = &cobra.Command{
Use: "clone",
Short: "Clones labels from one repository to another",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(label_cloneCmd).Standalone()
label_cloneCmd.Flags().BoolP("force", "f", false, "Overwrite labels in the destination repository")
labelCmd.AddCommand(label_cloneCmd)

carapace.Gen(label_cloneCmd).PositionalCompletion(
action.ActionOwnerRepositories(label_cloneCmd),
)
}
3 changes: 2 additions & 1 deletion completers/gh_completer/cmd/label_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ var label_createCmd = &cobra.Command{

func init() {
carapace.Gen(label_createCmd).Standalone()
label_createCmd.Flags().StringP("color", "c", "", "Color of the label, if not specified one will be selected at random")
label_createCmd.Flags().StringP("color", "c", "", "Color of the label")
label_createCmd.Flags().StringP("description", "d", "", "Description of the label")
label_createCmd.Flags().BoolP("force", "f", false, "Update the label color and description if label already exists")
labelCmd.AddCommand(label_createCmd)

carapace.Gen(label_createCmd).FlagCompletion(carapace.ActionMap{
Expand Down
30 changes: 30 additions & 0 deletions completers/gh_completer/cmd/label_edit.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/completers/gh_completer/cmd/action"
"github.com/rsteube/carapace-bin/pkg/actions/os"
"github.com/spf13/cobra"
)

var label_editCmd = &cobra.Command{
Use: "edit",
Short: "Edit a label",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(label_editCmd).Standalone()
label_editCmd.Flags().StringP("color", "c", "", "Color of the label")
label_editCmd.Flags().StringP("description", "d", "", "Description of the label")
label_editCmd.Flags().StringP("name", "n", "", "Name of the label")
labelCmd.AddCommand(label_editCmd)

carapace.Gen(label_editCmd).FlagCompletion(carapace.ActionMap{
"color": os.ActionHexColors(),
})

carapace.Gen(label_editCmd).PositionalCompletion(
action.ActionLabels(label_editCmd),
)
}
2 changes: 1 addition & 1 deletion completers/gh_completer/cmd/pr_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func init() {
pr_createCmd.Flags().StringSliceP("assignee", "a", []string{}, "Assign people by their `login`. Use \"@me\" to self-assign.")
pr_createCmd.Flags().StringP("base", "B", "", "The `branch` into which you want your code merged")
pr_createCmd.Flags().StringP("body", "b", "", "Body for the pull request")
pr_createCmd.Flags().StringP("body-file", "F", "", "Read body text from `file`")
pr_createCmd.Flags().StringP("body-file", "F", "", "Read body text from `file` (use \"-\" to read from standard input)")
pr_createCmd.Flags().BoolP("draft", "d", false, "Mark pull request as a draft")
pr_createCmd.Flags().BoolP("fill", "f", false, "Do not prompt for title/body and just use commit info")
pr_createCmd.Flags().StringP("head", "H", "", "The `branch` that contains commits for your pull request (default: current branch)")
Expand Down
7 changes: 4 additions & 3 deletions completers/gh_completer/cmd/repo_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (
)

var repo_listCmd = &cobra.Command{
Use: "list",
Short: "List repositories owned by user or organization",
Run: func(cmd *cobra.Command, args []string) {},
Use: "list",
Short: "List repositories owned by user or organization",
Aliases: []string{"ls"},
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
Expand Down

0 comments on commit 9971593

Please sign in to comment.