How to use the configargparse.FileType function in ConfigArgParse

To help you get started, we’ve selected a few ConfigArgParse examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cfstacks / stacks / stacks / cli.py View on Github external
# delete subparser
    parser_delete = subparsers.add_parser('delete', help='Delete an existing stack')
    parser_delete.add_argument('-f', '--follow', dest='events_follow', help='Follow stack events', action='store_true')
    parser_delete.add_argument('-y', '--yes', help='Confirm stack deletion.', action='store_true')
    parser_delete.add_argument('name')

    # events subparser
    parser_events = subparsers.add_parser('events', help='List events from a stack')
    parser_events.add_argument('name')
    parser_events.add_argument('-f', '--follow', dest='events_follow', action='store_true',
                               help='Poll for new events until stopped (overrides -n)')
    parser_events.add_argument('-n', '--lines', default=100, type=int)

    # diff subparser
    parser_create = subparsers.add_parser('diff', help='Print diff of current vs compiled template')
    parser_create.add_argument('-t', '--template', required=True, type=configargparse.FileType())
    # noinspection PyArgumentList
    parser_create.add_argument('-c', '--config', default='config.yaml',
                               env_var='STACKS_CONFIG', required=False,
                               type=_is_file)
    # noinspection PyArgumentList
    parser_create.add_argument('--config-dir', default='config.d',
                               env_var='STACKS_CONFIG_DIR', required=False,
                               type=_is_dir)
    parser_create.add_argument('name', nargs='?', default=None)
    # noinspection PyArgumentList
    parser_create.add_argument('-e', '--env', env_var='STACKS_ENV', required=False, default=None)
    parser_create.add_argument('-P', '--property', required=False, action='append')

    return parser, parser.parse_args()
github smarkets / marge-bot / marge / app.py View on Github external
help='config file path',
    )
    auth_token_group = parser.add_mutually_exclusive_group(required=True)
    auth_token_group.add_argument(
        '--auth-token',
        type=str,
        metavar='TOKEN',
        help=(
            'Your GitLab token.\n'
            'DISABLED because passing credentials on the command line is insecure:\n'
            'You can still set it via ENV variable or config file, or use "--auth-token-file" flag.\n'
        ),
    )
    auth_token_group.add_argument(
        '--auth-token-file',
        type=configargparse.FileType('rt'),
        metavar='FILE',
        help='Path to your GitLab token file.\n',
    )
    parser.add_argument(
        '--gitlab-url',
        type=str,
        required=True,
        metavar='URL',
        help='Your GitLab instance, e.g. "https://gitlab.example.com".\n',
    )
    ssh_key_group = parser.add_mutually_exclusive_group(required=True)
    ssh_key_group.add_argument(
        '--ssh-key',
        type=str,
        metavar='KEY',
        help=(
github NervanaSystems / neon / neon / util / argparser.py View on Github external
def add_yaml_arg(self):
        """
        Add the yaml file argument, this is needed for scripts that
        parse the model config from yaml files

        """
        # yaml configuration file
        self.add_argument('yaml_file',
                          type=configargparse.FileType('r'),
                          help='neon model specification file')