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

Fix commands with arguments that start with "-" #182

Merged
merged 5 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 5 additions & 3 deletions menuinst/_legacy/cwp.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@
from menuinst.knownfolders import FOLDERID, get_folder_path


def main():
def main(argv=None):
# call as: python cwp.py [--no-console] PREFIX ARGs...
parser = argparse.ArgumentParser()
parser.add_argument(
"--no-console", action="store_true", help="Create subprocess with CREATE_NO_WINDOW flag."
)
parser.add_argument("prefix", help="Prefix to be 'activated' before calling `args`.")
parser.add_argument("args", nargs="*", help="Command (and arguments) to be executed.")
parsed_args = parser.parse_args()
parser.add_argument(
"args", nargs=argparse.REMAINDER, help="Command (and arguments) to be executed."
)
parsed_args = parser.parse_args(argv)

no_console = parsed_args.no_console
prefix = parsed_args.prefix
Expand Down
21 changes: 21 additions & 0 deletions tests/_legacy/test_cwp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import sys
from subprocess import check_output

import pytest

cwp = pytest.importorskip("menuinst._legacy.cwp", reason="Windows only")


def test_cwp():
out = check_output(
[
sys.executable,
cwp.__file__,
sys.prefix,
"python",
"-c",
"import sys; print(sys.prefix)",
],
text=True,
)
assert out.strip() == sys.prefix
Loading