Skip to content

Add confirmation for alias overwrite #7780

@JunNishimura

Description

@JunNishimura

Describe the feature or problem you’d like to solve

We can add alias by gh alias set command. There are no problems when adding a new alias, but it seems to be a little problem when overwriting it.

Existing implementation can easily overwrite aliases that are already registered as follows.

$ gh alias set mypr 'pr list -s all -a JunNishimura'
- Adding alias for mypr: pr list -s all -a JunNishimura
✓ Added alias.
$ gh alias set mypr 'pr list'          
- Adding alias for mypr: pr list
✓ Changed alias mypr from pr list -s all -a JunNishimura to pr list

This is not a problem if the user overwrites the alias intentionally, but if the alias is accidentaly overwritten, the user is forced to re-register the alias. This is not kind to the user, I think.
(To output how the alias was changed is good behaviour.)

Proposed solution

When a user tries to overwrite the alias, a confirmation message is displayed as follows

$ gh alias set mypr 'pr list -s all -a JunNishimura'
- Adding alias for mypr: pr list -s all -a JunNishimura
✓ Added alias.
$ gh alias set mypr 'pr list'          
> "mypr" is already used. Do you want to overwrite? (y/N)

If the user says 'yes', the rest of the message continues as usual.

> "mypr" is already used. Do you want to overwrite? (y/N)
- Adding alias for mypr: pr list
✓ Changed alias mypr from pr list -s all -a JunNishimura to pr list

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementa request to improve CLIhelp wantedContributions welcome

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions