# Path: boussole/cli/console_script.py
# @click.group(context_settings=CONTEXT_SETTINGS)
# @click.option(
#     "-v",
#     "--verbose",
#     type=click.IntRange(min=0, max=5),
#     default=4,
#     metavar="INTEGER",
#     help=(
#         "An integer between 0 and 5, where '0' make a totaly "
#         "silent output and '5' set level to DEBUG (the most verbose "
#         "level). Default to '4' (Info level)."
#     )
# )
# @click.pass_context
# def cli_frontend(ctx, verbose):
#     """
#     Boussole is a commandline interface to build Sass projects using libsass.
# 
#     Every project will need a settings file containing all needed settings to
#     build it.
#     """
#     printout = True
#     if verbose == 0:
#         verbose = 1
#         printout = False
# 
#     # Verbosity is the inverse of logging levels
#     levels = [item for item in BOUSSOLE_LOGGER_CONF]
#     levels.reverse()
#     # Init the logger config
#     root_logger = init_logger(levels[verbose], printout=printout)
# 
#     # Init the default context that will be passed to commands
#     ctx.obj = {
#         "verbosity": verbose,
#         "logger": root_logger,
#     }
# 
# Path: boussole/conf/json_backend.py
# class SettingsBackendJson(SettingsBackendBase):
#     """
#     JSON backend for settings
# 
#     Attributes:
#         _default_filename: Filename for settings file to load.
#             Value is ``settings.json``.
#         _kind_name: Backend format name.
#             Value is ``json``.
#         _file_extension: Default filename extension.
#             Value is ``json``.
#     """
#     _default_filename = "boussole.json"
#     _kind_name = "json"
#     _file_extension = "json"
# 
#     def dump(self, content, filepath, indent=4):
#         """
#         Dump settings content to filepath.
# 
#         Args:
#             content (str): Settings content.
#             filepath (str): Settings file location.
#         """
#         with open(filepath, "w") as fp:
#             json.dump(content, fp, indent=indent)
# 
#     def parse(self, filepath, content):
#         """
#         Parse opened settings content using JSON parser.
# 
#         Args:
#             filepath (str): Settings object, depends from backend
#             content (str): Settings content from opened file, depends from
#                 backend.
# 
#         Raises:
#             boussole.exceptions.SettingsBackendError: If parser can not decode
#                 a valid JSON object.
# 
#         Returns:
#             dict: Dictionnary containing parsed setting elements.
# 
#         """
#         try:
#             parsed = json.loads(content)
#         except ValueError:
#             msg = "No JSON object could be decoded from file: {}"
#             raise SettingsBackendError(msg.format(filepath))
#         return parsed
# 
# Path: boussole/conf/yaml_backend.py
# class SettingsBackendYaml(SettingsBackendBase):
#     """
#     YAML backend for settings
# 
#     Use PyYaml for parsing and pyaml for dumping.
# 
#     Attributes:
#         _default_filename: Filename for settings file to load.
#             Value is ``settings.yml``.
#         _kind_name: Backend format name.
#             Value is ``yaml``.
#         _file_extension: Default filename extension.
#             Value is ``yml``.
#     """
#     _default_filename = "boussole.yml"
#     _kind_name = "yaml"
#     _file_extension = "yml"
# 
#     def dump(self, content, filepath, indent=4):
#         """
#         Dump settings content to filepath.
# 
#         Args:
#             content (str): Settings content.
#             filepath (str): Settings file location.
#         """
#         with open(filepath, "w") as fp:
#             pyaml.dump(content, dst=fp, indent=indent)
# 
#     def parse(self, filepath, content):
#         """
#         Parse opened settings content using YAML parser.
# 
#         Args:
#             filepath (str): Settings object, depends from backend
#             content (str): Settings content from opened file, depends from
#                 backend.
# 
#         Raises:
#             boussole.exceptions.SettingsBackendError: If parser can not decode
#                 a valid YAML object.
# 
#         Returns:
#             dict: Dictionnary containing parsed setting elements.
# 
#         """
#         try:
#             parsed = yaml.load(content, Loader=yaml.FullLoader)
#         except yaml.YAMLError as exc:
#             msg = "No YAML object could be decoded from file: {}\n{}"
#             raise SettingsBackendError(msg.format(filepath, exc))
#         return parsed


import json
import os
from click.testing import CliRunner
from boussole.cli.console_script import cli_frontend
from boussole.conf.json_backend import SettingsBackendJson
from boussole.conf.yaml_backend import SettingsBackendYaml
                "SOURCES_PATH": "scss",
                "TARGET_PATH": "css",
                "LIBRARY_PATHS": [],
                "OUTPUT_STYLES": "nested",
                "SOURCE_COMMENTS": False,
                "EXCLUDES": []
            }


def test_002(settings, caplog):
    """
    Error from given arguments (multiple identical paths)
    """
    runner = CliRunner()

    # Temporary isolated current dir
    with runner.isolated_filesystem():
        test_cwd = os.getcwd()

        sourcedir = os.path.join(test_cwd, "css")

        opts = [
            "startproject",
            "--basedir={}".format(test_cwd),
            "--config={}".format(JSON_FILENAME),
            "--sourcedir={}".format("css"),
            "--targetdir={}".format("css"),
        ]

        # Execute command with opts

# Path: boussole/cli/console_script.py
# @click.group(context_settings=CONTEXT_SETTINGS)
# @click.option(
#     "-v",
#     "--verbose",
#     type=click.IntRange(min=0, max=5),
#     default=4,
#     metavar="INTEGER",
#     help=(
#         "An integer between 0 and 5, where '0' make a totaly "
#         "silent output and '5' set level to DEBUG (the most verbose "
#         "level). Default to '4' (Info level)."
#     )
# )
# @click.pass_context
# def cli_frontend(ctx, verbose):
#     """
#     Boussole is a commandline interface to build Sass projects using libsass.
# 
#     Every project will need a settings file containing all needed settings to
#     build it.
#     """
#     printout = True
#     if verbose == 0:
#         verbose = 1
#         printout = False
# 
#     # Verbosity is the inverse of logging levels
#     levels = [item for item in BOUSSOLE_LOGGER_CONF]
#     levels.reverse()
#     # Init the logger config
#     root_logger = init_logger(levels[verbose], printout=printout)
# 
#     # Init the default context that will be passed to commands
#     ctx.obj = {
#         "verbosity": verbose,
#         "logger": root_logger,
#     }
# 
# Path: boussole/conf/json_backend.py
# class SettingsBackendJson(SettingsBackendBase):
#     """
#     JSON backend for settings
# 
#     Attributes:
#         _default_filename: Filename for settings file to load.
#             Value is ``settings.json``.
#         _kind_name: Backend format name.
#             Value is ``json``.
#         _file_extension: Default filename extension.
#             Value is ``json``.
#     """
#     _default_filename = "boussole.json"
#     _kind_name = "json"
#     _file_extension = "json"
# 
#     def dump(self, content, filepath, indent=4):
#         """
#         Dump settings content to filepath.
# 
#         Args:
#             content (str): Settings content.
#             filepath (str): Settings file location.
#         """
#         with open(filepath, "w") as fp:
#             json.dump(content, fp, indent=indent)
# 
#     def parse(self, filepath, content):
#         """
#         Parse opened settings content using JSON parser.
# 
#         Args:
#             filepath (str): Settings object, depends from backend
#             content (str): Settings content from opened file, depends from
#                 backend.
# 
#         Raises:
#             boussole.exceptions.SettingsBackendError: If parser can not decode
#                 a valid JSON object.
# 
#         Returns:
#             dict: Dictionnary containing parsed setting elements.
# 
#         """
#         try:
#             parsed = json.loads(content)
#         except ValueError:
#             msg = "No JSON object could be decoded from file: {}"
#             raise SettingsBackendError(msg.format(filepath))
#         return parsed
# 
# Path: boussole/conf/yaml_backend.py
# class SettingsBackendYaml(SettingsBackendBase):
#     """
#     YAML backend for settings
# 
#     Use PyYaml for parsing and pyaml for dumping.
# 
#     Attributes:
#         _default_filename: Filename for settings file to load.
#             Value is ``settings.yml``.
#         _kind_name: Backend format name.
#             Value is ``yaml``.
#         _file_extension: Default filename extension.
#             Value is ``yml``.
#     """
#     _default_filename = "boussole.yml"
#     _kind_name = "yaml"
#     _file_extension = "yml"
# 
#     def dump(self, content, filepath, indent=4):
#         """
#         Dump settings content to filepath.
# 
#         Args:
#             content (str): Settings content.
#             filepath (str): Settings file location.
#         """
#         with open(filepath, "w") as fp:
#             pyaml.dump(content, dst=fp, indent=indent)
# 
#     def parse(self, filepath, content):
#         """
#         Parse opened settings content using YAML parser.
# 
#         Args:
#             filepath (str): Settings object, depends from backend
#             content (str): Settings content from opened file, depends from
#                 backend.
# 
#         Raises:
#             boussole.exceptions.SettingsBackendError: If parser can not decode
#                 a valid YAML object.
# 
#         Returns:
#             dict: Dictionnary containing parsed setting elements.
# 
#         """
#         try:
#             parsed = yaml.load(content, Loader=yaml.FullLoader)
#         except yaml.YAMLError as exc:
#             msg = "No YAML object could be decoded from file: {}\n{}"
#             raise SettingsBackendError(msg.format(filepath, exc))
#         return parsed


# Path: tests/200_cli/003_startproject.py
import json
import os
from click.testing import CliRunner
from boussole.cli.console_script import cli_frontend
from boussole.conf.json_backend import SettingsBackendJson
from boussole.conf.yaml_backend import SettingsBackendYaml

                "SOURCES_PATH": "scss",
                "TARGET_PATH": "css",
                "LIBRARY_PATHS": [],
                "OUTPUT_STYLES": "nested",
                "SOURCE_COMMENTS": False,
                "EXCLUDES": []
            }


def test_002(settings, caplog):
    """
    Error from given arguments (multiple identical paths)
    """
    runner = CliRunner()

    # Temporary isolated current dir
    with runner.isolated_filesystem():
        test_cwd = os.getcwd()

        sourcedir = os.path.join(test_cwd, "css")

        opts = [
            "startproject",
            "--basedir={}".format(test_cwd),
            "--config={}".format(JSON_FILENAME),
            "--sourcedir={}".format("css"),
            "--targetdir={}".format("css"),
        ]

        # Execute command with opts

        result = runner.invoke(cli_frontend, opts)