# Path: src/gwf/conf.py
# CONFIG_DEFAULTS = {"verbose": "info", "backend": "local", "check_updates": True}
# class FileConfig:
#     def __init__(self, path, data, defaults=None):
#     def validator(self, key):
#         def _inner(func):
#     def _validate_value(self, key, value):
#     def get(self, key, default=None):
#     def __getitem__(self, key):
#     def __setitem__(self, key, value):
#     def __delitem__(self, key):
#     def __len__(self):
#     def __iter__(self):
#     def dump(self):
#     def load(cls, path, defaults=None):
# def config_from_path(path):


import click
from ..conf import config as _config



def humanbool(x):
    if x in ("true", "yes"):
        return True
    elif x in ("false", "no"):
        return False
    raise TypeError("x is not a boolean.")


def cast_value(value):
    types = [int, humanbool, str]
    for type_func in types:
        try:
            return type_func(value)
        except Exception:
            continue
    return value


@click.group()
def config():
    """Set, unset and get configuration."""


@config.command()
@click.argument("key")
def get(key):
    """Get the value of KEY."""

# Path: src/gwf/conf.py
# CONFIG_DEFAULTS = {"verbose": "info", "backend": "local", "check_updates": True}
# class FileConfig:
#     def __init__(self, path, data, defaults=None):
#     def validator(self, key):
#         def _inner(func):
#     def _validate_value(self, key, value):
#     def get(self, key, default=None):
#     def __getitem__(self, key):
#     def __setitem__(self, key, value):
#     def __delitem__(self, key):
#     def __len__(self):
#     def __iter__(self):
#     def dump(self):
#     def load(cls, path, defaults=None):
# def config_from_path(path):


# Path: src/gwf/plugins/config.py
import click
from ..conf import config as _config




def humanbool(x):
    if x in ("true", "yes"):
        return True
    elif x in ("false", "no"):
        return False
    raise TypeError("x is not a boolean.")


def cast_value(value):
    types = [int, humanbool, str]
    for type_func in types:
        try:
            return type_func(value)
        except Exception:
            continue
    return value


@click.group()
def config():
    """Set, unset and get configuration."""


@config.command()
@click.argument("key")
def get(key):
    """Get the value of KEY."""

    click.echo(_config.get(key, "<not set>"))