1def action_extensions(base_actions, project_path=None): 2 def echo(name, *args, **kwargs): 3 print(name, args, kwargs) 4 5 def verbose(name, ctx, args): 6 print('Output from test-verbose') 7 if args.verbose: 8 print('Verbose mode on') 9 10 # Add global options 11 extensions = { 12 'global_options': [ 13 { 14 'names': ['--test-0'], 15 'help': 'Non-deprecated option.', 16 'deprecated': False 17 }, 18 { 19 'names': ['--test-1'], 20 'help': 'Deprecated option 1.', 21 'deprecated': True 22 }, 23 { 24 'names': ['--test-2'], 25 'help': 'Deprecated option 2.', 26 'deprecated': 'Please update your parameters.' 27 }, 28 { 29 'names': ['--test-3'], 30 'help': 'Deprecated option 3.', 31 'deprecated': { 32 'custom_message': 'Please update your parameters.' 33 } 34 }, 35 { 36 'names': ['--test-4'], 37 'help': 'Deprecated option 4.', 38 'deprecated': { 39 'since': 'v4.0', 40 'removed': 'v5.0' 41 } 42 }, 43 { 44 'names': ['--test-5'], 45 'help': 'Deprecated option 5.', 46 'deprecated': { 47 'since': 'v2.0', 48 'removed': 'v3.0', 49 'exit_with_error': True 50 } 51 }, 52 ], 53 'actions': { 54 'test-verbose': { 55 'callback': verbose, 56 'help': 'Command that have some verbosity', 57 }, 58 'test-0': { 59 'callback': echo, 60 'help': 'Non-deprecated command 0', 61 'options': [ 62 { 63 'names': ['--test-sub-0'], 64 'help': 'Non-deprecated subcommand option 0', 65 'default': None, 66 }, 67 { 68 'names': ['--test-sub-1'], 69 'help': 'Deprecated subcommand option 1', 70 'default': None, 71 'deprecated': True 72 }, 73 ], 74 'arguments': [{ 75 'names': ['test-arg-0'], 76 }], 77 }, 78 'test-1': { 79 'callback': echo, 80 'help': 'Deprecated command 1', 81 'deprecated': 'Please use alternative command.' 82 }, 83 'test-2': { 84 'callback': echo, 85 'help': 'Deprecated command 2', 86 'deprecated': { 87 'exit_with_error': True 88 } 89 }, 90 }, 91 } 92 93 return extensions 94