Bug #12589
openHelp JSON output should be truly JSON formatted
Description
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1283793
Description of problem:
If a user request JSON-formatted help output from hammer, they are given all useful information as one large string within one "message" tag. The user would then have to parse that string to separate the useful information. If the output was already separated into a true JSON format, no additional processing would be needed and is already very useful.
Version-Release number of selected component (if applicable):
Nightly
How reproducible:
Always
Steps to Reproduce:
1. hammer --output=json host --help
Actual results:
{
"message": "Usage:\n hammer host [OPTIONS] SUBCOMMAND [ARG] ...\n\nParameters:\n SUBCOMMAND subcommand\n [ARG] ... subcommand arguments\n\nSubcommands:\n create Create a host\n delete Delete a host\n delete-parameter Delete parameter for a host.\n facts List all fact values\n info Show a host\n interface View and manage host's network interfaces\n list List all hosts\n puppet-classes List all Puppet classes\n puppetrun Force a Puppet agent run on the host\n reboot Reboot a host\n reports List all reports\n sc-params List all smart class parameters\n set-parameter Create or update parameter for a host.\n smart-variables List all smart variables\n start Power a host on\n status Get configuration status of host\n stop Power a host off\n update Update a host\n\nOptions:\n -h, --help print help\n"
}
Expected results:
Something like
{
"Usage": "hammer host [OPTIONS] SUBCOMMAND [ARG] ...",
"Parameters": {
"SUBCOMMAND": "subcommand",
"[ARG] ...": "subcommand arguments"
},
"Subcommands": {
"create": "Create a host",
"delete": "Delete a host",
"delete-parameter": "Delete parameter for a host.",
"facts": "List all fact values",
"info": "Show a host",
"interface": "View and manage host's network interfaces",
"list": "List all hosts",
"puppet-classes": "List all Puppet classes",
"puppetrun": "Force a Puppet agent run on the host",
"reboot": "Reboot a host",
"reports": "List all reports",
"sc-params": "List all smart class parameters",
"set-parameter": "Create or update parameter for a host.",
"smart-variables": "List all smart variables",
"start": "Power a host on",
"status": "Get configuration status of host",
"stop": "Power a host off",
"update": "Update a host"
}
}