Skip to content
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
1 change: 1 addition & 0 deletions .changelog/21.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Running `fil-profile` with no arguments now prints the help.
13 changes: 5 additions & 8 deletions filprofiler/_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,16 @@ def stage_1():
parser_run = subparsers.add_parser(
"run", help="Run a Python script or package", prefix_chars=[""], add_help=False,
)
# parser_run.add_argument(
# "-m",
# dest="module",
# action="store",
# help="Profile a module, equivalent to running with 'python -m <module>'",
# default="",
# )
parser_run.add_argument("rest", nargs=REMAINDER)
del subparsers, parser_run


def stage_2():
"""Main CLI interface. Presumes LD_PRELOAD etc. has been set by stage_1()."""
"""Main CLI interface.22 Presumes LD_PRELOAD etc. has been set by stage_1()."""
if len(sys.argv) == 1:
PARSER.print_help()
sys.exit(0)

arguments = PARSER.parse_args()
if arguments.license:
print(LICENSE)
Expand Down
11 changes: 11 additions & 0 deletions tests/test_endtoend.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,14 @@ def test_external_behavior():
assert url.startswith("file://")
assert url.endswith(".html")
assert os.path.exists(url[len("file://") :])


def test_no_args():
"""
Running fil-profile with no arguments gives same result as --help.
"""
no_args = run(["fil-profile"], stdout=PIPE, stderr=PIPE)
with_help = run(["fil-profile", "--help"], stdout=PIPE, stderr=PIPE)
assert no_args.returncode == with_help.returncode
assert no_args.stdout == with_help.stdout
assert no_args.stderr == with_help.stderr