Use argparse to add support for command line arguments to your program. Argparse supports adding sub commands to a primary command. It also supports making your subcommands mandatory or optional. Let me jump into example & explain.
import argparse, sys def sub_commands(add_arg): # Create child commands # use required option to make the option mandatory # Use metavar to print description for what kind of input is expected add_arg.add_argument("--state", help='Location to tf state file', default='state.xml', metavar='<file>', required=True) add_arg.add_argument("--varfile", help='Location to input variables files', default='var.xml', metavar='<file>', required=True) return add_arg def parse_options(args): parser = argparse.ArgumentParser(description='Any description to be displayed for the program.') # Create a subcommand subparsers = parser.add_subparsers(help='Add sub commands') # Define a primary command apply & set child/sub commands for apply add_p = subparsers.add_parser('apply', help='Apply your changes to system') sub_commands(add_p) add_p = subparsers.add_parser('destroy', help='Destroy the infra from system') sub_commands(add_p) add_p = subparsers.add_parser('plan', help='Verify your changes before apply') sub_commands(add_p) args = parser.parse_args() parser.print_help() return args