1 def arg(*args, **kwargs):
2 """Decorator for CLI args.
6 >>> @arg("name", help="Name of the new entity")
7 ... def entity_create(args):
11 add_arg(func, *args, **kwargs)
16 def add_arg(func, *args, **kwargs):
17 """Bind CLI arguments to a shell.py `do_foo` function."""
19 if not hasattr(func, 'arguments'):
22 # NOTE(sirp): avoid dups that can occur when the module is shared across
24 if (args, kwargs) not in func.arguments:
25 # Because of the semantics of decorator composition if we just append
26 # to the options list positional options will appear to be backwards.
27 func.arguments.insert(0, (args, kwargs))