diff --git a/jip/options.py b/jip/options.py index 7e79611..78f2929 100644 --- a/jip/options.py +++ b/jip/options.py @@ -705,13 +705,10 @@ def to_cmd(self): >>> o = Option("input", "-i", "--long", value="data.csv") >>> assert o.to_cmd() == '-i data.csv' - Hidden options and boolean options where the value is False or None are - represented as empty string. + Options with False or None value are represented as empty string. :returns: the cull command line representation of this option """ - if self.hidden: - return "" if self.nargs == 0: if len(self.value) == 0: return "" diff --git a/test/test_options.py b/test/test_options.py index dbba3a2..1ea2e58 100644 --- a/test/test_options.py +++ b/test/test_options.py @@ -36,6 +36,10 @@ def test_list_string_option(): assert str(o) == "t1 t2" assert o.to_cmd() == "-t t1 t2" +def test_hidden_option(): + o = Option("output", short="-o", hidden=True, value='Test') + assert o.to_cmd() == '-o Test' + def test_argparse_parser(): from argparse import ArgumentParser diff --git a/test/test_tools.py b/test/test_tools.py index 53ba836..b50b8e2 100644 --- a/test/test_tools.py +++ b/test/test_tools.py @@ -481,3 +481,31 @@ def test_tool_empty_list_options(): assert tool.options['output'].raw() == [] +def test_tool_hidden_option(): + @jip.tool("test") + class TestTool(object): + """\Test tool + + Usage: + test [-a ] [-b ] [-c] -i -o + + Inputs: + -i, --input The input + + Outputs: + -o, --output The output + + Options: + -a Option a + -b Option b + -c Options c (a flag) + """ + def setup(self): + self.opts['output'].hidden = True + + def get_command(self): + return '${options()} ${output|arg(">")}' + + tool = find('test') + tool.parse_args(['-i', 'input.txt', '-a', 'A', '-c', '-o', 'output.txt']) + assert tool.get_command() == ('bash', '-a A -c -i input.txt -o output.txt >output.txt')