def setup_command_line()

in enableDetective.py [0:0]


def setup_command_line(args = None) -> argparse.Namespace:
    """
    Configures and reads command line arguments.

    Returns:
        An argparse.Namespace object containing parsed arguments.

    Raises:
        argpare.ArgumentTypeError if an invalid value is used for
        master_account argument.
    """
    def _master_account_type(val: str, pattern: str = r'[0-9]{12}'):
        if not re.match(pattern, val):
            raise argparse.ArgumentTypeError
        return val

    class ParseCommaSeparatedKeyValuePairsAction(argparse.Action):
        def __call__(self, parser, namespace, values, option_string=None):
            setattr(namespace, self.dest, dict())
            for kv_pairs in values.split(","):
                key, _, value = kv_pairs.partition('=')
                getattr(namespace, self.dest)[key] = value

   # Setup command line arguments
    parser = argparse.ArgumentParser(description=('Link AWS Accounts to central '
                                                  'Detective Account.'))
    parser.add_argument('--master_account', type=_master_account_type,
                        required=True,
                        help="AccountId for Central AWS Account.")
    parser.add_argument('--input_file', type=argparse.FileType('r'),
                        required=True,
                        help=('Path to CSV file containing the list of '
                              'account IDs and Email addresses.'))
    parser.add_argument('--assume_role', type=str, required=True,
                        help="Role Name to assume in each account.")
    parser.add_argument('--enabled_regions', type=str,
                        help=('Regions to enable Detective. If not specified, '
                              'all available regions enabled.'))
    parser.add_argument('--disable_email', action='store_true',
                        help=('Don\'t send emails to the member accounts. Member '
                              'accounts must still accept the invitation before '
                              'they are added to the behavior graph.'))
    parser.add_argument('--tags',
                        action=ParseCommaSeparatedKeyValuePairsAction,
                        help='Comma-separated list of tag key-value pairs to be added '
                             'to any newly enabled Detective graphs. Values are optional '
                             'and are separated from keys by the equal sign (i.e. \'=\')')
    return parser.parse_args(args)