Skip to content

Commit

Permalink
cli_status: only show argv and config on error. #332
Browse files Browse the repository at this point in the history
  • Loading branch information
lemon24 committed Jun 16, 2024
1 parent 352dcfe commit 88f32d2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 32 deletions.
19 changes: 10 additions & 9 deletions src/reader/_plugins/cli_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,18 @@ def get_output(config, now, output, exc):
output = output.rstrip()
if output:
parts.append(output)
parts.extend(
[
'\n## argv',
'\n'.join(map(shlex.quote, sys.argv[1:])),
'\n## config',
dump_config(config.merge_all().data.get('cli')).rstrip(),
]
)

if tb:
parts.extend(['\n# traceback', tb.rstrip()])
parts.extend(
[
'\n## traceback',
tb.rstrip(),
'\n## argv',
'\n'.join(map(shlex.quote, sys.argv[1:])),
'\n## config',
dump_config(config.merge_all().data.get('cli')).rstrip(),
]
)

parts.append('\n')
return '\n\n'.join(parts)
Expand Down
24 changes: 1 addition & 23 deletions tests/test_plugins_cli_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,7 @@ def invoke(*args):
assert entry.title == 'command: update'
assert result.output in entry.content[0].value

def clean_value(value, output):
return (
value.replace(output, '<OUTPUT>\n')
.replace(db_path, '<DB>')
.replace(str(data_dir), '<DATA>')
)

assert clean_value(entry.content[0].value, result.output) == OUTPUT
assert entry.content[0].value.replace(result.output, '<OUTPUT>\n') == OUTPUT


OUTPUT = """\
Expand All @@ -57,21 +50,6 @@ def clean_value(value, output):
<OUTPUT>
## argv
one
two
## config
reader:
url: <DB>
feed_root: <DATA>
plugins:
reader._plugins.cli_status.init_cli: null
"""


Expand Down

0 comments on commit 88f32d2

Please sign in to comment.