Skip to content
This repository has been archived by the owner on Oct 7, 2023. It is now read-only.

Commit

Permalink
Improve CLI args (#21)
Browse files Browse the repository at this point in the history
* improve cli commands

* bump version

* add test
  • Loading branch information
JoshKarpel authored Nov 27, 2020
1 parent dfab7e2 commit b761ef0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions dis_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
@click.option(
"-p/-P",
"--paging/--no-paging",
"--pager/--no-pager",
default=None,
help="Enable/disable displaying output using the system pager. Default: enabled if the output is taller than your terminal window.",
)
Expand All @@ -79,6 +80,11 @@ def cli(
Any number of TARGETs may be passed; they will be displayed sequentially.
"""
if len(target) == 0:
ctx = click.get_current_context()
click.echo(ctx.get_help())
return

# Make sure the cwd (implicit starting point for the import path) is actually on PYTHONPATH.
# Since Python automatically adds the cwd on startup, this is only really necessary in the test suite,
# but it's convenient to do it here for sanity.
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = dis_cli
version = 0.2.0
version = 0.2.1
description = A tool to inspect disassembled Python code on the command line.
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down
7 changes: 7 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,10 @@ def test_column_width(terminal_width, line_num_width, ratio, expected):
calculate_column_widths(line_num_width, ratio=ratio, terminal_width=terminal_width)
== expected
)


def test_no_targets_prints_help(cli):
result = cli([])

assert result.exit_code == 0
assert "TARGET" in result.output

0 comments on commit b761ef0

Please sign in to comment.