class SubOptions2(Options): opts = [ Opt('charlie', 'c', store=False), Opt('delta', 'd', store=str), Opt('golf', 'g', store=True), Opt('hotel', 'h', store=int) ]
class AppOptions(Options): cmds = {'cmd1|command1': SubOptions1, 'cmd2|command2': SubOptions2} opts = [ Opt('alpha', 'a', store=True), Opt('bravo', 'b', store=int), Opt('charlie', 'c', store=1), Opt('delta', 'd', store=str) ]
class TestSubOptions(Options): desc = """ short sub-command description string Long sub-command description string. """ usage = '[options]' opts = [ Opt('alpha', 'a', 'alpha help string', store=int), Opt('echo', 'e', 'echo help string', store=True), Opt('foxtrot', '', 'foxtrot help string', store=str) ]
class SubOptions1(Options): cmds = {'cmd1-1': SubSubOptions1} opts = [ Opt('charlie', 'c', store=True), Opt('delta', 'd', store=float), Opt('echo', 'e', store={ 'a': 4, 'b': 3, 'c': 2, 'd': 1 }) ]
class TestOptions(Options): desc = """ short command description string Long command description string. """ usage = '[options]' cmds = {'subcmd|sub-command': TestSubOptions} opts = [ Opt('alpha', 'a', 'alpha help string', store=True), Opt('bravo', 'b', 'bravo help string', store=int, metavar='INT'), Opt('charlie', '', 'charlie help string', store=True), Opt('delta', '', 'delta help string', store=str) ]
class TestOptions1(Options): opts = [ Opt('alpha', 'a', store=True), Opt('bravo', 'b', store=True), Opt('charlie', 'c', store=self.opt_c), Opt('delta', 'd', store={ '00': 1, '01': 2, '10': 3, '11': 4 }), Opt('echo', 'e', store=int), Opt('fox-trot', 'f', handler='fox_trot') ] def fox_trot(self_, arg): try: self_['fox-trot'].append(arg) except: self_['fox-trot'] = [arg] def parse_args(self_, *args): self.parse_args(*args)
class TestOptions(BaseOptions): opts = [ Opt('charlie', 'c', store=True), Opt('delta', 'd', store=str) ]
class BaseOptions(Options): opts = [ Opt('alpha', 'a', store=True), Opt('bravo', 'b', store=int) ]
class SubSubOptions1(Options): opts = [ Opt('echo', 'e', store=str), Opt('fox-trot', 'f', store=True) ]