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

json.tool ought to have a help flag #65199

Closed
benjaminp opened this issue Mar 20, 2014 · 7 comments
Closed

json.tool ought to have a help flag #65199

benjaminp opened this issue Mar 20, 2014 · 7 comments
Labels
easy stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@benjaminp
Copy link
Contributor

BPO 21000
Nosy @rhettinger, @pitrou, @benjaminp, @berkerpeksag, @vadmium
Files
  • issue21000.diff
  • issue21000_v2.diff
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2014-03-22.04:17:58.174>
    created_at = <Date 2014-03-20.18:56:04.505>
    labels = ['easy', 'type-feature', 'library']
    title = 'json.tool ought to have a help flag'
    updated_at = <Date 2014-03-22.04:17:58.172>
    user = 'https://github.com/benjaminp'

    bugs.python.org fields:

    activity = <Date 2014-03-22.04:17:58.172>
    actor = 'python-dev'
    assignee = 'none'
    closed = True
    closed_date = <Date 2014-03-22.04:17:58.174>
    closer = 'python-dev'
    components = ['Library (Lib)']
    creation = <Date 2014-03-20.18:56:04.505>
    creator = 'benjamin.peterson'
    dependencies = []
    files = ['34534', '34554']
    hgrepos = []
    issue_num = 21000
    keywords = ['patch', 'easy']
    message_count = 7.0
    messages = ['214261', '214367', '214369', '214395', '214413', '214439', '214440']
    nosy_count = 6.0
    nosy_names = ['rhettinger', 'pitrou', 'benjamin.peterson', 'python-dev', 'berker.peksag', 'martin.panter']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue21000'
    versions = ['Python 3.5']

    @benjaminp
    Copy link
    Contributor Author

    I current get this behavior:
    % python3 -m json.tool -h
    Traceback (most recent call last):
      File "/usr/lib64/python3.3/runpy.py", line 160, in _run_module_as_main
        "__main__", fname, loader, pkg_name)
      File "/usr/lib64/python3.3/runpy.py", line 73, in _run_code
        exec(code, run_globals)
      File "/usr/lib64/python3.3/json/tool.py", line 40, in <module>
        main()
      File "/usr/lib64/python3.3/json/tool.py", line 21, in main
        infile = open(sys.argv[1], 'r')
    FileNotFoundError: [Errno 2] No such file or directory: '-h'

    Instead of that, json.tool should show a helpful message expalining what it does in response to the -h or --help flags.

    @benjaminp benjaminp added stdlib Python modules in the Lib dir easy type-feature A feature request or enhancement labels Mar 20, 2014
    @benjaminp
    Copy link
    Contributor Author

    Very nice, but your help message still doesn't explain what json.tool does. :)

    @pitrou
    Copy link
    Member

    pitrou commented Mar 21, 2014

    Perhaps this thing should use argparse?

    @berkerpeksag
    Copy link
    Member

    Here's a new patch. Changes:

    • Updated the output of -h option
    • Added documentation
    • Switched to argparse

    @rhettinger
    Copy link
    Contributor

    This looks like a nice improvement.

    @benjaminp
    Copy link
    Contributor Author

    Thanks a lot for the excellent patch!

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 22, 2014

    New changeset a2ad16e86e60 by Benjamin Peterson in branch 'default':
    improve the command-line interface of json.tool (closes bpo-21000)
    http://hg.python.org/cpython/rev/a2ad16e86e60

    @python-dev python-dev mannequin closed this as completed Mar 22, 2014
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    easy stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants