mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-02-21 12:28:44 +00:00
commands/show: Improved formatting of show command
This commit is contained in:
parent
833c3dd0a0
commit
635ebc1f4d
@ -40,10 +40,14 @@ class ShowCommand(Command):
|
|||||||
plugin = get_plugin(name)
|
plugin = get_plugin(name)
|
||||||
if plugin:
|
if plugin:
|
||||||
rst_output = get_rst_from_plugin(plugin)
|
rst_output = get_rst_from_plugin(plugin)
|
||||||
|
plugin_name = plugin.name
|
||||||
|
kind = '{}:'.format(plugin.kind)
|
||||||
else:
|
else:
|
||||||
target = get_target_description(name)
|
target = get_target_description(name)
|
||||||
if target:
|
if target:
|
||||||
rst_output = get_rst_from_target(target)
|
rst_output = get_rst_from_target(target)
|
||||||
|
plugin_name = target.name
|
||||||
|
kind = 'target:'
|
||||||
|
|
||||||
if not rst_output:
|
if not rst_output:
|
||||||
raise NotFoundError('Could not find plugin or alias "{}"'.format(name))
|
raise NotFoundError('Could not find plugin or alias "{}"'.format(name))
|
||||||
@ -51,10 +55,15 @@ class ShowCommand(Command):
|
|||||||
if which('pandoc'):
|
if which('pandoc'):
|
||||||
p = Popen(['pandoc', '-f', 'rst', '-t', 'man'], stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
p = Popen(['pandoc', '-f', 'rst', '-t', 'man'], stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
||||||
output, _ = p.communicate(rst_output)
|
output, _ = p.communicate(rst_output)
|
||||||
|
|
||||||
# Make sure to double escape back slashes
|
# Make sure to double escape back slashes
|
||||||
output = output.replace('\\', '\\\\\\')
|
output = output.replace('\\', '\\\\\\')
|
||||||
# Correctly format the tile of the man page
|
|
||||||
output = output.replace('.SH', '.TH', 1)
|
# Correctly format the title and page number of the man page
|
||||||
|
title, body = output.split('\n', 1)
|
||||||
|
title = '.TH {}{} 1'.format(kind, plugin_name)
|
||||||
|
output = '\n'.join([title, body])
|
||||||
|
|
||||||
call('echo "{}" | man -l -'.format(escape_double_quotes(output)), shell=True)
|
call('echo "{}" | man -l -'.format(escape_double_quotes(output)), shell=True)
|
||||||
else:
|
else:
|
||||||
print rst_output
|
print rst_output
|
||||||
|
Loading…
x
Reference in New Issue
Block a user