def test_un_camel_case(self): self.assertEqual('jira', base.un_camel_case('JIRA')) self.assertEqual('jira_tool', base.un_camel_case('JIRATool')) self.assertEqual('jira_tool', base.un_camel_case('jira_tool')) self.assertEqual('jira_tool', base.un_camel_case('jira tool')) self.assertEqual('jira_tool', base.un_camel_case('Jira tool')) self.assertEqual('jira_tool', base.un_camel_case(' Jira tool')) self.assertEqual('status_csv', base.un_camel_case(' StatusCSV'))
this = base.get_program_name() if (len(args) == 1) and (args[0] in ACTIONS): action = args[0] print('Usage for %s %s' % (this, action)) ACTIONS[action](workspace=None)(['--help']) else: print(USAGE % {'this': this}) FLAGS.print_usage() # -------------------------------------------------------------------------------------------------- # Map: action-name (dash-separated) -> CLI Action class : ACTIONS = dict( map(lambda cls: (base.un_camel_case(cls.__name__, separator='-'), cls), Action.__subclasses__() + [Run, Test, Checkstyle, Scalastyle, Lint, GeneratePom, Help]) ) class FijiBuildTool(cli.Action): """Command-line tool dispatcher for fiji-build.""" def __init__(self, **kwargs): super().__init__( help_flag=cli.HelpFlag.ADD_NO_HANDLE, **kwargs ) def register_flags(self):
this = base.get_program_name() if (len(args) == 1) and (args[0] in ACTIONS): action = args[0] print('Usage for %s %s' % (this, action)) ACTIONS[action](workspace=None)(['--help']) else: print(USAGE % {'this': this}) FLAGS.print_usage() # -------------------------------------------------------------------------------------------------- # Map: action-name (dash-separated) -> CLI Action class : ACTIONS = dict( map( lambda cls: (base.un_camel_case(cls.__name__, separator='-'), cls), Action.__subclasses__() + [Run, Test, Checkstyle, Scalastyle, Lint, GeneratePom, Help])) class KijiBuildTool(cli.Action): """Command-line tool dispatcher for kiji-build.""" def __init__(self, **kwargs): super().__init__(help_flag=cli.HelpFlag.ADD_NO_HANDLE, **kwargs) def register_flags(self): self.flags.add_string( name='do', default=None, help=('Action to perform:\n%s.' % ',\n'.join(map(lambda name: ' - ' + name, sorted(ACTIONS)))),
def get_name(cls): """Returns this action's name.""" name = cls.NAME if name is None: name = cls.__name__ return base.un_camel_case(name, separator='-')