Merge pull request #6725 from cli/cmbrose/rename-repo-shorthand
Codespaces: Use -R for --repo shorthand and deprecate -r
This commit is contained in:
commit
6f1d149da3
4 changed files with 31 additions and 3 deletions
|
|
@ -284,3 +284,19 @@ func (c codespace) hasUnsavedChanges() bool {
|
|||
func (c codespace) running() bool {
|
||||
return c.State == api.CodespaceStateAvailable
|
||||
}
|
||||
|
||||
// addDeprecatedRepoShorthand adds a -r parameter (deprecated shorthand for --repo)
|
||||
// which instructs the user to use -R instead.
|
||||
func addDeprecatedRepoShorthand(cmd *cobra.Command, target *string) error {
|
||||
cmd.Flags().StringVarP(target, "repo-deprecated", "r", "", "(Deprecated) Shorthand for --repo")
|
||||
|
||||
if err := cmd.Flags().MarkHidden("repo-deprecated"); err != nil {
|
||||
return fmt.Errorf("error marking `-r` shorthand as hidden: %w", err)
|
||||
}
|
||||
|
||||
if err := cmd.Flags().MarkShorthandDeprecated("repo-deprecated", "use `-R` instead"); err != nil {
|
||||
return fmt.Errorf("error marking `-r` shorthand as deprecated: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,7 +81,11 @@ func newCreateCmd(app *App) *cobra.Command {
|
|||
},
|
||||
}
|
||||
|
||||
createCmd.Flags().StringVarP(&opts.repo, "repo", "r", "", "repository name with owner: user/repo")
|
||||
createCmd.Flags().StringVarP(&opts.repo, "repo", "R", "", "repository name with owner: user/repo")
|
||||
if err := addDeprecatedRepoShorthand(createCmd, &opts.repo); err != nil {
|
||||
fmt.Fprintf(app.io.ErrOut, "%v\n", err)
|
||||
}
|
||||
|
||||
createCmd.Flags().StringVarP(&opts.branch, "branch", "b", "", "repository branch")
|
||||
createCmd.Flags().StringVarP(&opts.location, "location", "l", "", "location: {EastUs|SouthEastAsia|WestEurope|WestUs2} (determined automatically if not provided)")
|
||||
createCmd.Flags().StringVarP(&opts.machine, "machine", "m", "", "hardware specifications for the VM")
|
||||
|
|
|
|||
|
|
@ -66,7 +66,11 @@ func newDeleteCmd(app *App) *cobra.Command {
|
|||
|
||||
deleteCmd.Flags().StringVarP(&opts.codespaceName, "codespace", "c", "", "Name of the codespace")
|
||||
deleteCmd.Flags().BoolVar(&opts.deleteAll, "all", false, "Delete all codespaces")
|
||||
deleteCmd.Flags().StringVarP(&opts.repoFilter, "repo", "r", "", "Delete codespaces for a `repository`")
|
||||
deleteCmd.Flags().StringVarP(&opts.repoFilter, "repo", "R", "", "Delete codespaces for a `repository`")
|
||||
if err := addDeprecatedRepoShorthand(deleteCmd, &opts.repoFilter); err != nil {
|
||||
fmt.Fprintf(app.io.ErrOut, "%v\n", err)
|
||||
}
|
||||
|
||||
deleteCmd.Flags().BoolVarP(&opts.skipConfirm, "force", "f", false, "Skip confirmation for codespaces that contain unsaved changes")
|
||||
deleteCmd.Flags().Uint16Var(&opts.keepDays, "days", 0, "Delete codespaces older than `N` days")
|
||||
deleteCmd.Flags().StringVarP(&opts.orgName, "org", "o", "", "The `login` handle of the organization (admin-only)")
|
||||
|
|
|
|||
|
|
@ -44,7 +44,11 @@ func newListCmd(app *App) *cobra.Command {
|
|||
}
|
||||
|
||||
listCmd.Flags().IntVarP(&opts.limit, "limit", "L", 30, "Maximum number of codespaces to list")
|
||||
listCmd.Flags().StringVarP(&opts.repo, "repo", "r", "", "Repository name with owner: user/repo")
|
||||
listCmd.Flags().StringVarP(&opts.repo, "repo", "R", "", "Repository name with owner: user/repo")
|
||||
if err := addDeprecatedRepoShorthand(listCmd, &opts.repo); err != nil {
|
||||
fmt.Fprintf(app.io.ErrOut, "%v\n", err)
|
||||
}
|
||||
|
||||
listCmd.Flags().StringVarP(&opts.orgName, "org", "o", "", "The `login` handle of the organization to list codespaces for (admin-only)")
|
||||
listCmd.Flags().StringVarP(&opts.userName, "user", "u", "", "The `username` to list codespaces for (used with --org)")
|
||||
cmdutil.AddJSONFlags(listCmd, &exporter, api.CodespaceFields)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue