def get_usage(self, program_name=None): """Get the commandline usage string for this experiment.""" program_name = os.path.relpath(program_name or sys.argv[0] or 'Dummy', self.base_dir) commands = OrderedDict(self.gather_commands()) options = gather_command_line_options() long_usage = format_usage(program_name, self.doc, commands, options) # internal usage is a workaround because docopt cannot handle spaces # in program names. So for parsing we use 'dummy' as the program name. # for printing help etc. we want to use the actual program name. internal_usage = format_usage('dummy', self.doc, commands, options) short_usage = printable_usage(long_usage) return short_usage, long_usage, internal_usage
def get_usage(self, program_name=None): """Get the commandline usage string for this experiment.""" program_name = os.path.relpath(program_name or sys.argv[0] or 'Dummy', self.base_dir) commands = OrderedDict(self.gather_commands()) options = gather_command_line_options() long_usage = format_usage(program_name, self.doc, commands, options) # internal usage is a workaround because docopt cannot handle spaces # in program names. So for parsing we use 'dummy' as the program name. # for printing help etc. we want to use the actual program name. internal_usage = format_usage('dummy', self.doc, commands, options) short_usage = printable_usage(long_usage) return short_usage, long_usage, internal_usage
def test_parse_individual_arguments(argv, expected): options = gather_command_line_options() usage = format_usage("test.py", "", {}, options) argv = shlex.split(argv) plain = docopt(usage, [], help=False) args = docopt(usage, argv, help=False) plain.update(expected) assert args == plain
def test_parse_individual_arguments(argv, expected): options = gather_command_line_options() usage = format_usage("test.py", "", {}, options) argv = shlex.split(argv) plain = docopt(usage, [], help=False) args = docopt(usage, argv, help=False) plain.update(expected) assert args == plain
def get_usage(self, program_name=None): """Get the commandline usage string for this experiment.""" program_name = program_name or sys.argv[0] commands = OrderedDict(self.gather_commands()) options = gather_command_line_options() long_usage = format_usage(program_name, self.doc, commands, options) short_usage = printable_usage(long_usage) return short_usage, long_usage
def get_usage(self, program_name=None): """Get the commandline usage string for this experiment.""" program_name = program_name or sys.argv[0] commands = OrderedDict(self.gather_commands()) options = gather_command_line_options() long_usage = format_usage(program_name, self.doc, commands, options) short_usage = printable_usage(long_usage) return short_usage, long_usage