{"action":"created","issue":{"url":"https://api.github.com/repos/StackStorm/st2/issues/2992","repository_url":"https://api.github.com/repos/StackStorm/st2","labels_url":"https://api.github.com/repos/StackStorm/st2/issues/2992/labels{/name}","comments_url":"https://api.github.com/repos/StackStorm/st2/issues/2992/comments","events_url":"https://api.github.com/repos/StackStorm/st2/issues/2992/events","html_url":"https://github.com/StackStorm/st2/pull/2992","id":186952416,"number":2992,"title":"De-Clutter Help Output","user":{"login":"Mierdin","id":4230395,"avatar_url":"https://avatars.githubusercontent.com/u/4230395?v=3","gravatar_id":"","url":"https://api.github.com/users/Mierdin","html_url":"https://github.com/Mierdin","followers_url":"https://api.github.com/users/Mierdin/followers","following_url":"https://api.github.com/users/Mierdin/following{/other_user}","gists_url":"https://api.github.com/users/Mierdin/gists{/gist_id}","starred_url":"https://api.github.com/users/Mierdin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mierdin/subscriptions","organizations_url":"https://api.github.com/users/Mierdin/orgs","repos_url":"https://api.github.com/users/Mierdin/repos","events_url":"https://api.github.com/users/Mierdin/events{/privacy}","received_events_url":"https://api.github.com/users/Mierdin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-11-03T00:05:13Z","updated_at":"2016-11-03T00:16:27Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/StackStorm/st2/pulls/2992","html_url":"https://github.com/StackStorm/st2/pull/2992","diff_url":"https://github.com/StackStorm/st2/pull/2992.diff","patch_url":"https://github.com/StackStorm/st2/pull/2992.patch"},"body":"I'm really just familiarizing myself with the way that the `st2client` package is put together - these changes may not be desired, but after re-familiarizing myself with the less-used features of `argparse` and with the `st2client` package, I figured I would at least post the results of my efforts.\r\n\r\nI noticed that some of the help output contained a long, ugly line of subcommands within curly braces, right before redundantly outputting those same subcommands in a pretty tabular format:\r\n\r\n```\r\nvagrant@st2test:~$ st2 -h\r\nusage: st2 [-h] [--version] [--url BASE_URL] [--auth-url AUTH_URL]\r\n           [--api-url API_URL] [--api-version API_VERSION] [--cacert CACERT]\r\n           [--config-file CONFIG_FILE] [--print-config] [--skip-config]\r\n           [--debug]\r\n           {action,action-alias,auth,apikey,execution,key,pack,policy,policy-type,rule,run,runner,sensor,trace,trigger,trigger-instance,webhook,timer,rule-enforcement}\r\n           ...\r\n\r\nCLI for StackStorm event-driven automation platform. https://stackstorm.com\r\n\r\npositional arguments:\r\n  {action,action-alias,auth,apikey,execution,key,pack,policy,policy-type,rule,run,runner,sensor,trace,trigger,trigger-instance,webhook,timer,rule-enforcement}\r\n    action              An activity that happens as a response to the external\r\n                        event.\r\n    action-alias        Action aliases.\r\n\r\n    (remainder of output omitted...)\r\n```\r\n\r\nThis is a default behavior of the argparse library when using subcommands. The [argparse documentation](https://docs.python.org/2/library/argparse.html?highlight=add_subparsers#argparse.ArgumentParser.add_subparsers) states that this can be controlled through the \"metavar\" argument when running `add_subparsers()`.\r\n\r\nSo, this PR does just that - in the case of the global help output, the metavar argument for this function call in `shell.py` is set to an empty string, which removes this entirely.\r\n\r\nThere's also a call to this function in `commands/resource.py`, but in this case, the argument `help` has been removed, and what was being set there is now being passed as the `metavar` argument. This provides a more consistent output.\r\n\r\nThe result of these changes are shown below. First, to the global help output:\r\n\r\n```\r\n(st2client) C02RF1RYFVH8:st2client oswaldm$ st2 -h\r\nusage: st2 [-h] [--version] [--url BASE_URL] [--auth-url AUTH_URL]\r\n           [--api-url API_URL] [--api-version API_VERSION] [--cacert CACERT]\r\n           [--config-file CONFIG_FILE] [--print-config] [--skip-config]\r\n           [--debug]\r\n           ...\r\n\r\nCLI for StackStorm event-driven automation platform. https://stackstorm.com\r\n\r\npositional arguments:\r\n\r\n    action              An activity that happens as a response to the external\r\n                        event.\r\n    action-alias        Action aliases.\r\n\r\n    (remainder of output omitted...)\r\n```\r\n\r\nIn addition, any subcommand for resource management would also be affected, such as `st2 pack`:\r\n\r\n```\r\n(st2client) C02RF1RYFVH8:st2client oswaldm$ st2 pack -h\r\nusage: st2 pack [-h] List of commands for managing packs. ...\r\n\r\nA group of related integration resources: actions, rules, and sensors.\r\n\r\npositional arguments:\r\n  List of commands for managing packs.\r\n    list                Get the list of packs.\r\n    register            Register a pack: sync all file changes with DB.\r\n    install             Install new packs.\r\n    remove              Remove packs.\r\n    search              Search for a pack in the directory.\r\n    show                Get information about a pack from the index.\r\n    config              Configure a pack based on config schema.\r\n\r\noptional arguments:\r\n  -h, --help            show this help message and exit\r\n```"},"comment":{"url":"https://api.github.com/repos/StackStorm/st2/issues/comments/258037988","html_url":"https://github.com/StackStorm/st2/pull/2992#issuecomment-258037988","issue_url":"https://api.github.com/repos/StackStorm/st2/issues/2992","id":258037988,"user":{"login":"Mierdin","id":4230395,"avatar_url":"https://avatars.githubusercontent.com/u/4230395?v=3","gravatar_id":"","url":"https://api.github.com/users/Mierdin","html_url":"https://github.com/Mierdin","followers_url":"https://api.github.com/users/Mierdin/followers","following_url":"https://api.github.com/users/Mierdin/following{/other_user}","gists_url":"https://api.github.com/users/Mierdin/gists{/gist_id}","starred_url":"https://api.github.com/users/Mierdin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mierdin/subscriptions","organizations_url":"https://api.github.com/users/Mierdin/orgs","repos_url":"https://api.github.com/users/Mierdin/repos","events_url":"https://api.github.com/users/Mierdin/events{/privacy}","received_events_url":"https://api.github.com/users/Mierdin/received_events","type":"User","site_admin":false},"created_at":"2016-11-03T00:16:27Z","updated_at":"2016-11-03T00:16:27Z","body":"@emedvedev Oops, that was an unintended side-effect of me replacing the `help` arg with the `metavar` arg directly. Let me tinker some more and see if I can improve on that"}}
{"actor":{"display_login":"Mierdin"}}