-
-
Notifications
You must be signed in to change notification settings - Fork 52
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 #2302 from carapace-sh/gh-updates
gh: updates from 2.45.0
- Loading branch information
Showing
12 changed files
with
174 additions
and
8 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,21 @@ | ||
package action | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/gh" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func ActionTeams(cmd *cobra.Command) carapace.Action { | ||
return carapace.ActionCallback(func(c carapace.Context) carapace.Action { | ||
repo, err := repoOverride(cmd) | ||
if err != nil { | ||
return carapace.ActionMessage(err.Error()) | ||
} | ||
return gh.ActionTeams(gh.OwnerOpts{ | ||
Host: repo.RepoHost(), | ||
Owner: repo.RepoOwner(), | ||
}) | ||
|
||
}) | ||
} |
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,33 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/carapace-sh/carapace-bin/completers/gh_completer/cmd/action" | ||
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/gh" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var project_linkCmd = &cobra.Command{ | ||
Use: "link [<number>] [flag]", | ||
Short: "Link a project to a repository or a team", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(project_linkCmd).Standalone() | ||
|
||
project_linkCmd.Flags().String("owner", "", "Login of the owner. Use \"@me\" for the current user.") | ||
project_linkCmd.PersistentFlags().StringP("repo", "R", "", "Select another repository using the `[HOST/]OWNER/REPO` format") | ||
project_linkCmd.Flags().StringP("team", "T", "", "The team to be linked to this project") | ||
projectCmd.AddCommand(project_linkCmd) | ||
|
||
carapace.Gen(project_linkCmd).FlagCompletion(carapace.ActionMap{ | ||
"owner": gh.ActionOwners(gh.HostOpts{}), | ||
"repo": action.ActionRepoOverride(project_linkCmd), | ||
"team": action.ActionTeams(project_linkCmd), | ||
}) | ||
|
||
carapace.Gen(project_linkCmd).PositionalCompletion( | ||
action.ActionProjects(project_linkCmd, action.ProjectOpts{Open: true}), | ||
) | ||
} |
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,33 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/carapace-sh/carapace-bin/completers/gh_completer/cmd/action" | ||
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/gh" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var project_unlinkCmd = &cobra.Command{ | ||
Use: "unlink [<number>] [flag]", | ||
Short: "Unlink a project from a repository or a team", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(project_unlinkCmd).Standalone() | ||
|
||
project_unlinkCmd.Flags().String("owner", "", "Login of the owner. Use \"@me\" for the current user.") | ||
project_unlinkCmd.PersistentFlags().StringP("repo", "R", "", "Select another repository using the `[HOST/]OWNER/REPO` format") | ||
project_unlinkCmd.Flags().StringP("team", "T", "", "The team to be unlinked from this project") | ||
projectCmd.AddCommand(project_unlinkCmd) | ||
|
||
carapace.Gen(project_unlinkCmd).FlagCompletion(carapace.ActionMap{ | ||
"owner": gh.ActionOwners(gh.HostOpts{}), | ||
"repo": action.ActionRepoOverride(project_linkCmd), | ||
"team": action.ActionTeams(project_linkCmd), | ||
}) | ||
|
||
carapace.Gen(project_unlinkCmd).PositionalCompletion( | ||
action.ActionProjects(project_linkCmd, action.ProjectOpts{Open: true}), | ||
) | ||
} |
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
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
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
2 changes: 1 addition & 1 deletion
2
...ters/gh_completer/cmd/action/languages.go → pkg/actions/tools/gh/languages.go
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package action | ||
package gh | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
|
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,38 @@ | ||
package gh | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/carapace-sh/carapace" | ||
"github.com/carapace-sh/carapace/pkg/style" | ||
) | ||
|
||
type team struct { | ||
Name string `json:"name"` | ||
ID int `json:"id"` | ||
Description string `json:"description"` | ||
Privacy string `json:"privacy"` | ||
} | ||
|
||
// ActionTeams completes teams | ||
// | ||
// first-team (description of first team) | ||
// second-team (description of second team) | ||
func ActionTeams(opts OwnerOpts) carapace.Action { | ||
return carapace.ActionCallback(func(c carapace.Context) carapace.Action { | ||
var queryResult []team | ||
return apiV3Action(opts.repo(), fmt.Sprintf(`orgs/%v/teams`, opts.Owner), &queryResult, func() carapace.Action { | ||
vals := make([]string, 0) | ||
for _, team := range queryResult { | ||
switch team.Privacy { | ||
case "secret": | ||
vals = append(vals, team.Name, team.Description, style.Carapace.KeywordNegative) | ||
default: | ||
vals = append(vals, team.Name, team.Description, style.Default) | ||
} | ||
} | ||
return carapace.ActionStyledValuesDescribed(vals...) | ||
}) | ||
|
||
}) | ||
} |