[docs]defcmd(*args,**overrides):"""Set the overrides for a command."""defwrap(cb):cb=cb.__func__ifinspect.ismethod(cb)elsecbif'doc'inoverrides:overrides['doc']=textwrap.dedent(overrides['doc']).strip()cb.cli2=overridesreturncbifargsandnotoverrides:returnwrap(args[0])returnwrap
[docs]defarg(name,**kwargs):"""Set the overrides for an argument."""defwrap(cb):cb=cb.__func__ifinspect.ismethod(cb)elsecboverrides=getattr(cb,'cli2_'+name,None)ifoverridesisNone:try:setattr(cb,'cli2_'+name,{})exceptAttributeError:setattr(cb.__func__,'cli2_'+name,{})try:overrides=getattr(cb,'cli2_'+name)exceptAttributeError:overrides=getattr(cb.__func__,'cli2_'+name)overrides.update(kwargs)returncbreturnwrap