Skip to content

Commit

Permalink
Raise error if --user and --target arguments are used together
Browse files Browse the repository at this point in the history
  • Loading branch information
sinscary committed Feb 24, 2020
1 parent ea47be5 commit 4ed5019
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions news/7249.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Raise error if --user and --target are used together in command
19 changes: 14 additions & 5 deletions src/pip/_internal/cli/main_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ def parse_command(args):
# the subcommand name
cmd_name = args_else[0]

validate_command_args(cmd_name, args_else)

# all the args without the subcommand
cmd_args = args[:]
cmd_args.remove(cmd_name)

return cmd_name, cmd_args


def validate_command_args(cmd_name, args_else):
# type: (str, List[str]) -> None
if cmd_name not in commands_dict:
guess = get_similar_commands(cmd_name)

Expand All @@ -92,8 +103,6 @@ def parse_command(args):

raise CommandError(' - '.join(msg))

# all the args without the subcommand
cmd_args = args[:]
cmd_args.remove(cmd_name)

return cmd_name, cmd_args
if set(['--user', '--target']).issubset(set(args_else)):
error_msg = '--user and --target cant not be used together.'
raise CommandError(error_msg)

0 comments on commit 4ed5019

Please sign in to comment.