Пример #1
0
def inspect(config_file, profile):
    """Inspect existing configuration/profile."""

    try:
        section = load_profile_from_files(
            [config_file] if config_file else None, profile)

        click.echo("Configuration file: {}".format(config_file if config_file else "auto-detected"))
        click.echo("Profile: {}".format(profile if profile else "auto-detected"))
        click.echo("---")
        for key, val in section.items():
            click.echo("{} = {}".format(key, val))

    except (ValueError, ConfigFileReadError, ConfigFileParseError) as e:
        click.echo(e)
Пример #2
0
def inspect_config(ctx, param, value):
    if not value or ctx.resilient_parsing:
        return

    config_file = ctx.params.get('config_file')
    profile = ctx.params.get('profile')

    try:
        section = load_profile_from_files(
            [config_file] if config_file else None, profile)

        click.echo("Config file: {}".format(
            config_file if config_file else "auto-detected"))
        click.echo(
            "Profile: {}".format(profile if profile else "auto-detected"))
        click.echo("---")
        for key, val in section.items():
            click.echo("{} = {}".format(key, val))

    except (ValueError, ConfigFileReadError, ConfigFileParseError) as e:
        click.echo(e)

    ctx.exit()