Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh: updates from v2.32.0 #1724

Merged
merged 1 commit into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 0 additions & 42 deletions completers/gh_completer/cmd/action/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,48 +108,6 @@ func repoOverride(cmd *cobra.Command) (ghrepo.Interface, error) {
return ghrepo.New("", ""), nil
}

func ActionAuthScopes() carapace.Action {
return carapace.ActionCallback(func(c carapace.Context) carapace.Action {
return carapace.ActionValuesDescribed(
"admin:gpg_key", "Fully manage GPG keys.",
"admin:org", "Fully manage the organization and its teams, projects, and memberships.",
"admin:org_hook", "Grants read, write, ping, and delete access to organization hooks.",
"admin:public_key", "Fully manage public keys.",
"admin:repo_hook", "Grants read, write, ping, and delete access to repository hooks in public and private repositories.",
"codespace", "Full control of codespaces",
"delete:packages", "Grants access to delete packages from GitHub Packages.",
"delete_repo", "Grants access to delete adminable repositories.",
"gist", "Grants write access to gists.",
"notifications", "Grants read access to a user's notifications",
"project", "Grants read/write access to user and organization projects",
"public_repo", "Limits access to public repositories.",
"read:discussion", "Allows read access for team discussions.",
"read:gpg_key", "List and view details for GPG keys.",
"read:org", "Read-only access to organization membership, organization projects, and team membership.",
"read:packages", "Grants access to download or install packages from GitHub Packages.",
"read:project", "Grants read only access to user and organization projects",
"read:public_key", "List and view details for public keys.",
"read:repo_hook", "Grants read and ping access to hooks in public or private repositories.",
"read:user", "Grants access to read a user's profile data.",
"repo", "Grants full access to private and public repositories.",
"repo:invite", "Grants accept/decline abilities for invitations to collaborate on a repository.",
"repo:status", "Grants read/write access to public and private repository commit statuses.",
"repo_deployment", "Grants access to deployment statuses for public and private repositories.",
"security_events", "Grants read and write access to security events in the code scanning API.",
"user", "Grants read/write access to profile info only.",
"user:email", "Grants read access to a user's email addresses.",
"user:follow", "Grants access to follow or unfollow other users.",
"workflow", "Grants the ability to add and update GitHub Actions workflow files.",
"write:discussion", "Allows read and write access for team discussions.",
"write:gpg_key", "Create, list, and view details for GPG keys.",
"write:org", "Read and write access to organization membership, organization projects, and team membership.",
"write:packages", "Grants access to upload or publish a package in GitHub Packages.",
"write:public_key", "Create, list, and view details for public keys.",
"write:repo_hook", "Grants read, write, and ping access to hooks in public or private repositories.",
).Invoke(c).ToMultiPartsA(":")
})
}

// https://yourbasic.org/golang/formatting-byte-size-to-human-readable-format/
func byteCountSI(b int) string {
const unit = 1000
Expand Down
17 changes: 17 additions & 0 deletions completers/gh_completer/cmd/action/cache.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package action

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/gh"
"github.com/spf13/cobra"
)

func ActionCaches(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.ActionCaches(gh.RepoOpts{Host: repo.RepoHost(), Owner: repo.RepoOwner(), Name: repo.RepoName()})
})
}
17 changes: 17 additions & 0 deletions completers/gh_completer/cmd/action/ruleset.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package action

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/gh"
"github.com/spf13/cobra"
)

func ActionRulesets(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.ActionRulesets(gh.RepoOpts{Host: repo.RepoHost(), Owner: repo.RepoOwner(), Name: repo.RepoName()})
})
}
19 changes: 19 additions & 0 deletions completers/gh_completer/cmd/actions.go
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 actionsCmd = &cobra.Command{
Use: "actions",
Short: "Learn about working with GitHub Actions",
Hidden: true,
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(actionsCmd).Standalone()

rootCmd.AddCommand(actionsCmd)
}
10 changes: 5 additions & 5 deletions completers/gh_completer/cmd/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ var apiCmd = &cobra.Command{
func init() {
carapace.Gen(apiCmd).Standalone()

apiCmd.Flags().Duration("cache", 0, "Cache the response, e.g. \"3600s\", \"60m\", \"1h\"")
apiCmd.Flags().StringArrayP("field", "F", []string{}, "Add a typed parameter in `key=value` format")
apiCmd.Flags().StringArrayP("header", "H", []string{}, "Add a HTTP request header in `key:value` format")
apiCmd.Flags().String("cache", "", "Cache the response, e.g. \"3600s\", \"60m\", \"1h\"")
apiCmd.Flags().StringSliceP("field", "F", []string{}, "Add a typed parameter in `key=value` format")
apiCmd.Flags().StringSliceP("header", "H", []string{}, "Add a HTTP request header in `key:value` format")
apiCmd.Flags().String("hostname", "", "The GitHub hostname for the request (default \"github.com\")")
apiCmd.Flags().BoolP("include", "i", false, "Include HTTP response status line and headers in the output")
apiCmd.Flags().String("input", "", "The `file` to use as body for the HTTP request (use \"-\" to read from standard input)")
apiCmd.Flags().StringP("jq", "q", "", "Query to select values from the response using jq syntax")
apiCmd.Flags().StringP("method", "X", "GET", "The HTTP method for the request")
apiCmd.Flags().StringP("method", "X", "", "The HTTP method for the request")
apiCmd.Flags().Bool("paginate", false, "Make additional HTTP requests to fetch all pages of results")
apiCmd.Flags().StringSliceP("preview", "p", []string{}, "GitHub API preview `names` to request (without the \"-preview\" suffix)")
apiCmd.Flags().StringArrayP("raw-field", "f", []string{}, "Add a string parameter in `key=value` format")
apiCmd.Flags().StringSliceP("raw-field", "f", []string{}, "Add a string parameter in `key=value` format")
apiCmd.Flags().Bool("silent", false, "Do not print the response body")
apiCmd.Flags().StringP("template", "t", "", "Format JSON output using a Go template; see \"gh help formatting\"")
rootCmd.AddCommand(apiCmd)
Expand Down
19 changes: 19 additions & 0 deletions completers/gh_completer/cmd/auth_gitCredential.go
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 auth_gitCredentialCmd = &cobra.Command{
Use: "git-credential",
Short: "Implements git credential helper protocol",
Hidden: true,
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(auth_gitCredentialCmd).Standalone()

authCmd.AddCommand(auth_gitCredentialCmd)
}
5 changes: 4 additions & 1 deletion completers/gh_completer/cmd/auth_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/completers/gh_completer/cmd/action"
"github.com/rsteube/carapace-bin/pkg/actions/tools/gh"
"github.com/spf13/cobra"
)

Expand All @@ -19,13 +20,15 @@ func init() {
auth_loginCmd.Flags().StringP("hostname", "h", "", "The hostname of the GitHub instance to authenticate with")
auth_loginCmd.Flags().Bool("insecure-storage", false, "Save authentication credentials in plain text instead of credential store")
auth_loginCmd.Flags().StringSliceP("scopes", "s", []string{}, "Additional authentication scopes to request")
auth_loginCmd.Flags().Bool("secure-storage", false, "Save authentication credentials in secure credential store")
auth_loginCmd.Flags().BoolP("web", "w", false, "Open a browser to authenticate")
auth_loginCmd.Flags().Bool("with-token", false, "Read token from standard input")
auth_loginCmd.Flag("secure-storage").Hidden = true
authCmd.AddCommand(auth_loginCmd)

carapace.Gen(auth_loginCmd).FlagCompletion(carapace.ActionMap{
"git-protocol": carapace.ActionValues("ssh", "https"),
"hostname": action.ActionConfigHosts(),
"scopes": action.ActionAuthScopes().UniqueList(","),
"scopes": gh.ActionAuthScopes().MultiParts(":").UniqueList(","),
})
}
11 changes: 10 additions & 1 deletion completers/gh_completer/cmd/auth_refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/completers/gh_completer/cmd/action"
"github.com/rsteube/carapace-bin/pkg/actions/tools/gh"
"github.com/spf13/cobra"
)

Expand All @@ -17,11 +18,19 @@ func init() {

auth_refreshCmd.Flags().StringP("hostname", "h", "", "The GitHub host to use for authentication")
auth_refreshCmd.Flags().Bool("insecure-storage", false, "Save authentication credentials in plain text instead of credential store")
auth_refreshCmd.Flags().StringSliceP("remove-scopes", "r", []string{}, "Authentication scopes to remove from gh")
auth_refreshCmd.Flags().Bool("reset-scopes", false, "Reset authentication scopes to the default minimum set of scopes")
auth_refreshCmd.Flags().StringSliceP("scopes", "s", []string{}, "Additional authentication scopes for gh to have")
auth_refreshCmd.Flags().Bool("secure-storage", false, "Save authentication credentials in secure credential store")
auth_refreshCmd.Flag("secure-storage").Hidden = true
authCmd.AddCommand(auth_refreshCmd)

carapace.Gen(auth_refreshCmd).FlagCompletion(carapace.ActionMap{
"hostname": action.ActionConfigHosts(),
"scopes": action.ActionAuthScopes().UniqueList(","),
"remove-scopes": carapace.ActionCallback(func(c carapace.Context) carapace.Action {
hostname := auth_refreshCmd.Flag("hostname").Value.String()
return gh.ActionCurrentAuthScopes(hostname).MultiParts(":").UniqueList(",")
}),
"scopes": gh.ActionAuthScopes().MultiParts(":").UniqueList(","),
})
}
2 changes: 2 additions & 0 deletions completers/gh_completer/cmd/auth_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ func init() {
carapace.Gen(auth_tokenCmd).Standalone()

auth_tokenCmd.Flags().StringP("hostname", "h", "", "The hostname of the GitHub instance authenticated with")
auth_tokenCmd.Flags().Bool("secure-storage", false, "Search only secure credential store for authentication token")
auth_tokenCmd.Flag("secure-storage").Hidden = true
authCmd.AddCommand(auth_tokenCmd)

carapace.Gen(auth_tokenCmd).FlagCompletion(carapace.ActionMap{
Expand Down
2 changes: 1 addition & 1 deletion completers/gh_completer/cmd/browse.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func init() {
browseCmd.PersistentFlags().StringP("repo", "R", "", "Select another repository using the `[HOST/]OWNER/REPO` format")
browseCmd.Flags().BoolP("settings", "s", false, "Open repository settings")
browseCmd.Flags().BoolP("wiki", "w", false, "Open repository wiki")
browseCmd.Flag("commit").NoOptDefVal = "last"
browseCmd.Flag("commit").NoOptDefVal = " "
rootCmd.AddCommand(browseCmd)

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

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

var cacheCmd = &cobra.Command{
Use: "cache <command>",
Short: "Manage Github Actions caches",
GroupID: "actions",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(cacheCmd).Standalone()

cacheCmd.PersistentFlags().StringP("repo", "R", "", "Select another repository using the `[HOST/]OWNER/REPO` format")
rootCmd.AddCommand(cacheCmd)

carapace.Gen(cacheCmd).FlagCompletion(carapace.ActionMap{
"repo": action.ActionRepoOverride(cacheCmd),
})
}
24 changes: 24 additions & 0 deletions completers/gh_completer/cmd/cache_delete.go
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/gh_completer/cmd/action"
"github.com/spf13/cobra"
)

var cache_deleteCmd = &cobra.Command{
Use: "delete [<cache-id>| <cache-key> | --all]",
Short: "Delete Github Actions caches",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(cache_deleteCmd).Standalone()

cache_deleteCmd.Flags().BoolP("all", "a", false, "Delete all caches")
cacheCmd.AddCommand(cache_deleteCmd)

carapace.Gen(cache_deleteCmd).PositionalCompletion(
action.ActionCaches(cache_deleteCmd),
)
}
27 changes: 27 additions & 0 deletions completers/gh_completer/cmd/cache_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace/pkg/style"
"github.com/spf13/cobra"
)

var cache_listCmd = &cobra.Command{
Use: "list",
Short: "List Github Actions caches",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(cache_listCmd).Standalone()

cache_listCmd.Flags().StringP("limit", "L", "", "Maximum number of caches to fetch")
cache_listCmd.Flags().StringP("order", "O", "", "Order of caches returned: {asc|desc}")
cache_listCmd.Flags().StringP("sort", "S", "", "Sort fetched caches: {created_at|last_accessed_at|size_in_bytes}")
cacheCmd.AddCommand(cache_listCmd)

carapace.Gen(cache_listCmd).FlagCompletion(carapace.ActionMap{
"order": carapace.ActionValues("asc", "desc").StyleF(style.ForKeyword),
"sort": carapace.ActionValues("created_at", "last_accessed_at", "size_in_bytes"),
})
}
2 changes: 2 additions & 0 deletions completers/gh_completer/cmd/codespace_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ func init() {
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().StringP("repo-deprecated", "r", "", "(Deprecated) Shorthand for --repo")
codespace_createCmd.Flags().String("retention-period", "", "allowed time after shutting down before the codespace is automatically deleted (maximum 30 days), e.g. \"1h\", \"72h\"")
codespace_createCmd.Flags().BoolP("status", "s", false, "show status of post-create command and dotfiles")
codespace_createCmd.Flags().BoolP("web", "w", false, "create codespace from browser, cannot be used with --display-name, --idle-timeout, or --retention-period")
codespace_createCmd.Flag("repo-deprecated").Hidden = true
codespaceCmd.AddCommand(codespace_createCmd)

// TODO devcontainer-path
Expand Down
4 changes: 3 additions & 1 deletion completers/gh_completer/cmd/codespace_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ func init() {

codespace_deleteCmd.Flags().Bool("all", false, "Delete all codespaces")
codespace_deleteCmd.PersistentFlags().StringP("codespace", "c", "", "Name of the codespace")
codespace_deleteCmd.Flags().Uint16("days", 0, "Delete codespaces older than `N` days")
codespace_deleteCmd.Flags().String("days", "", "Delete codespaces older than `N` days")
codespace_deleteCmd.Flags().BoolP("force", "f", false, "Skip confirmation for codespaces that contain unsaved changes")
codespace_deleteCmd.Flags().StringP("org", "o", "", "The `login` handle of the organization (admin-only)")
codespace_deleteCmd.PersistentFlags().StringP("repo", "R", "", "Filter codespace selection by repository name (user/repo)")
codespace_deleteCmd.Flags().StringP("repo-deprecated", "r", "", "(Deprecated) Shorthand for --repo")
codespace_deleteCmd.PersistentFlags().String("repo-owner", "", "Filter codespace selection by repository owner (username or org)")
codespace_deleteCmd.Flags().StringP("user", "u", "", "The `username` to delete codespaces for (used with --org)")
codespace_deleteCmd.Flag("repo-deprecated").Hidden = true
codespaceCmd.AddCommand(codespace_deleteCmd)

carapace.Gen(codespace_deleteCmd).FlagCompletion(carapace.ActionMap{
Expand Down
2 changes: 2 additions & 0 deletions completers/gh_completer/cmd/codespace_edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ func init() {

codespace_editCmd.PersistentFlags().StringP("codespace", "c", "", "Name of the codespace")
codespace_editCmd.Flags().StringP("display-name", "d", "", "Set the display name")
codespace_editCmd.Flags().String("displayName", "", "display name")
codespace_editCmd.Flags().StringP("machine", "m", "", "Set hardware specifications for the VM")
codespace_editCmd.PersistentFlags().StringP("repo", "R", "", "Filter codespace selection by repository name (user/repo)")
codespace_editCmd.PersistentFlags().String("repo-owner", "", "Filter codespace selection by repository owner (username or org)")
codespace_editCmd.Flag("displayName").Hidden = true
codespaceCmd.AddCommand(codespace_editCmd)

carapace.Gen(codespace_editCmd).FlagCompletion(carapace.ActionMap{
Expand Down
2 changes: 2 additions & 0 deletions completers/gh_completer/cmd/codespace_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ func init() {
codespace_listCmd.Flags().StringP("limit", "L", "", "Maximum number of codespaces to list")
codespace_listCmd.Flags().StringP("org", "o", "", "The `login` handle of the organization to list codespaces for (admin-only)")
codespace_listCmd.Flags().StringP("repo", "R", "", "Repository name with owner: user/repo")
codespace_listCmd.Flags().StringP("repo-deprecated", "r", "", "(Deprecated) Shorthand for --repo")
codespace_listCmd.Flags().StringP("template", "t", "", "Format JSON output using a Go template; see \"gh help formatting\"")
codespace_listCmd.Flags().StringP("user", "u", "", "The `username` to list codespaces for (used with --org)")
codespace_listCmd.Flags().BoolP("web", "w", false, "List codespaces in the web browser, cannot be used with --user or --org")
codespace_listCmd.Flag("repo-deprecated").Hidden = true
codespaceCmd.AddCommand(codespace_listCmd)

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

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/completers_release/gh_completer/cmd/action"
"github.com/rsteube/carapace-bin/pkg/actions/tools/gh"
"github.com/spf13/cobra"
)

var codespace_selectCmd = &cobra.Command{
Use: "select",
Short: "Select a Codespace",
Hidden: true,
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(codespace_selectCmd).Standalone()

codespace_selectCmd.PersistentFlags().StringP("codespace", "c", "", "Name of the codespace")
codespace_selectCmd.Flags().StringP("file", "f", "", "Output file path")
codespace_selectCmd.PersistentFlags().StringP("repo", "R", "", "Filter codespace selection by repository name (user/repo)")
codespace_selectCmd.PersistentFlags().String("repo-owner", "", "Filter codespace selection by repository owner (username or org)")
codespaceCmd.AddCommand(codespace_selectCmd)

carapace.Gen(codespace_selectCmd).FlagCompletion(carapace.ActionMap{
"codespace": action.ActionCodespaces(),
"file": carapace.ActionFiles(),
"repo": gh.ActionOwnerRepositories(gh.HostOpts{}),
"repo-owner": gh.ActionOwners(gh.HostOpts{}),
})
}
2 changes: 2 additions & 0 deletions completers/gh_completer/cmd/codespace_ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ func init() {
codespace_sshCmd.PersistentFlags().StringP("repo", "R", "", "Filter codespace selection by repository name (user/repo)")
codespace_sshCmd.PersistentFlags().String("repo-owner", "", "Filter codespace selection by repository owner (username or org)")
codespace_sshCmd.Flags().String("server-port", "", "SSH server port number (0 => pick unused)")
codespace_sshCmd.Flags().Bool("stdio", false, "Proxy sshd connection to stdio")
codespace_sshCmd.Flag("stdio").Hidden = true
codespaceCmd.AddCommand(codespace_sshCmd)

carapace.Gen(codespace_sshCmd).FlagCompletion(carapace.ActionMap{
Expand Down
Loading