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

run app appargs fix for -- double-dash #268

Merged
merged 39 commits into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
68d47ad
Parse args fix for run subcommand with -- arg.
itsayellow Oct 31, 2019
545cfdf
Add -- appargs test to pip run tests.
itsayellow Nov 1, 2019
5564a65
Merge branch 'master' of https://github.com/pipxproject/pipx into app…
itsayellow Nov 4, 2019
6285d96
Merge branch 'master' of https://github.com/pipxproject/pipx into app…
itsayellow Nov 4, 2019
b30eb49
Merge branch 'master' of https://github.com/pipxproject/pipx into app…
itsayellow Nov 4, 2019
2708fcf
Make test_appargs_doubledash() more of a unit test.
itsayellow Nov 4, 2019
6a039d5
Fix argparse appargs logic.
itsayellow Nov 4, 2019
ee5396e
Fix test_appargs_doubledash, add more cases.
itsayellow Nov 4, 2019
ed2a50d
Merge branch 'master' of https://github.com/pipxproject/pipx into app…
itsayellow Nov 4, 2019
d711d79
Merge branch 'master' of https://github.com/pipxproject/pipx into app…
itsayellow Nov 5, 2019
6f24a63
Merge branch 'master' of https://github.com/pipxproject/pipx into app…
itsayellow Nov 12, 2019
e6cf1e7
Merge remote-tracking branch 'upstream/master' into appargs_fix
itsayellow Dec 6, 2019
40c6ede
Revert main.py to master.
itsayellow Dec 7, 2019
016517c
Add required -- arg before app.
itsayellow Dec 8, 2019
a881724
Revamp pip run arguments so -- precedes app as required.
itsayellow Dec 8, 2019
a85465c
Fixed assert of failed pipx run.
itsayellow Dec 8, 2019
7aed752
Remove redundant tests.
itsayellow Dec 8, 2019
2321d2f
Add required -- to pipx run args.
itsayellow Dec 8, 2019
b3c27dc
Merge remote-tracking branch 'upstream/master' into appargs_fix
itsayellow Dec 9, 2019
5f38a99
Revert "Add required -- arg before app."
itsayellow Dec 11, 2019
294fcbc
Modify tests for non-required --.
itsayellow Dec 11, 2019
5df25ca
Revert makefile.
itsayellow Dec 11, 2019
1ca0437
Fix one more test, remove --.
itsayellow Dec 11, 2019
1303f33
Add help text to pipx run about --.
itsayellow Dec 11, 2019
4136844
Print note if appargs has -- before it.
itsayellow Dec 13, 2019
b3df42c
Replace print to stderr with logging.warning.
itsayellow Dec 13, 2019
a528f05
Merge remote-tracking branch 'upstream/master' into appargs_fix
itsayellow Dec 15, 2019
04387f6
Merge remote-tracking branch 'upstream/master' into appargs_fix
itsayellow Dec 16, 2019
cb5b3c2
Revert "Replace print to stderr with logging.warning."
itsayellow Dec 16, 2019
fba8d27
Revert "Print note if appargs has -- before it."
itsayellow Dec 16, 2019
43e4f71
Revert "Add help text to pipx run about --."
itsayellow Dec 16, 2019
fb89906
Change binary_args -> app_args.
itsayellow Dec 16, 2019
a072c47
Change arg parsing so -- after app is passed to appargs.
itsayellow Dec 16, 2019
b046588
Merge remote-tracking branch 'upstream/master' into appargs_fix
itsayellow Dec 16, 2019
5a80914
Fix help to show required app.
itsayellow Dec 16, 2019
d713428
Fix check_args() bug and error message.
itsayellow Dec 16, 2019
cbabde3
Black reformat.
itsayellow Dec 16, 2019
8267ff9
Add another -- test for pipx run.
itsayellow Dec 16, 2019
64307e6
Add comments.
itsayellow Dec 16, 2019
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
16 changes: 15 additions & 1 deletion src/pipx/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,12 +573,26 @@ def setup(args):
)


def parse_args(parser):
parsed_args = parser.parse_args()
if parsed_args.command == "run":
app_i = -(len(parsed_args.appargs) + 1)
# sys.argv[app_i] is:
# app if no deleted "--" post-app in sys.argv
# first item of appargs if "--" deleted post-app in sys.argv

# insert another "--" if first "--" is after app and no previous one
if "--" in sys.argv[app_i:] and "--" not in sys.argv[:app_i]:
sys.argv.insert(sys.argv.index("--", app_i), "--")
return parser.parse_args()


def cli() -> int:
"""Entry point from command line"""
try:
parser = get_command_parser()
argcomplete.autocomplete(parser)
parsed_pipx_args = parser.parse_args()
parsed_pipx_args = parse_args(parser)
setup(parsed_pipx_args)
if not parsed_pipx_args.command:
parser.print_help()
Expand Down
21 changes: 21 additions & 0 deletions tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,24 @@ def test_run_script_from_internet(pipx_temp_env, capsys):
"6bdfbb6e9c1132b1c38fdd2f195d4a24c540c324/pipx-demo.py",
]
)


def test_appargs_doubledash(capsys):
run_pipx_cli(["run", "pycowsay", "--", "hello"])
captured = capsys.readouterr()
assert "< -- hello >" not in captured.out
run_pipx_cli(["run", "pycowsay", "hello", "--"])
captured = capsys.readouterr()
assert "< hello -- >" not in captured.out
run_pipx_cli(["run", "pycowsay", "--"])
captured = capsys.readouterr()
assert "< -- >" not in captured.out
run_pipx_cli(["run", "--", "pycowsay", "--", "hello"])
captured = capsys.readouterr()
assert "< -- hello >" not in captured.out
run_pipx_cli(["run", "--", "pycowsay", "hello", "--"])
captured = capsys.readouterr()
assert "< hello -- >" not in captured.out
run_pipx_cli(["run", "--", "pycowsay", "--"])
captured = capsys.readouterr()
assert "< -- >" not in captured.out
itsayellow marked this conversation as resolved.
Show resolved Hide resolved