Skip to content

Commit c4d7744

Browse files
committed
Add 'remove' command as an alias to 'uninstall'
1 parent 6a7bf94 commit c4d7744

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

news/8130.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add 'remove' command as an alias to 'uninstall'.

src/pip/_internal/cli/main_parser.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
ConfigOptionParser,
1010
UpdatingDefaultsHelpFormatter,
1111
)
12-
from pip._internal.commands import commands_dict, get_similar_commands
12+
from pip._internal.commands import (
13+
command_aliases,
14+
commands_dict,
15+
get_similar_commands,
16+
)
1317
from pip._internal.exceptions import CommandError
1418
from pip._internal.utils.misc import get_pip_version, get_prog
1519
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
@@ -81,9 +85,11 @@ def parse_command(args):
8185
sys.exit()
8286

8387
# the subcommand name
84-
cmd_name = args_else[0]
88+
cmd_alias = cmd_name = args_else[0]
8589

86-
if cmd_name not in commands_dict:
90+
if cmd_alias in command_aliases:
91+
cmd_name = command_aliases[cmd_alias]
92+
elif cmd_name not in commands_dict:
8793
guess = get_similar_commands(cmd_name)
8894

8995
msg = ['unknown command "{}"'.format(cmd_name)]
@@ -94,6 +100,6 @@ def parse_command(args):
94100

95101
# all the args without the subcommand
96102
cmd_args = args[:]
97-
cmd_args.remove(cmd_name)
103+
cmd_args.remove(cmd_alias)
98104

99105
return cmd_name, cmd_args

src/pip/_internal/commands/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
1818

1919
if MYPY_CHECK_RUNNING:
20-
from typing import Any
20+
from typing import Any, Dict
2121
from pip._internal.cli.base_command import Command
2222

2323

@@ -94,6 +94,8 @@
9494
)),
9595
]) # type: OrderedDict[str, CommandInfo]
9696

97+
command_aliases = {'remove': 'uninstall'} # type: Dict[str, str]
98+
9799

98100
def create_command(name, **kwargs):
99101
# type: (str, **Any) -> Command

0 commit comments

Comments
 (0)