"""
Silique (https://www.silique.fr)
Copyright (C) 2024-2026

This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
details.

You should have received a copy of the GNU Lesser General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""

from ..utils import _


def get_rougail_config(
    *,
    backward_compatibility=True,
) -> dict:
    if backward_compatibility:
        main_namespace_default = "rougail"
    else:
        main_namespace_default = "null"
    options = f"""
main_namespace:
  description: {_("Main namespace name")}
  default: {main_namespace_default}
  alternative_name: s
  mandatory: false
  disabled:
    jinja: >-
      {{{{ 'directory' not in _.step.structural and 'string' not in _.step.structural }}}}
    return_type: boolean
    description: {_('directory or string is not in "_.step.structural"')}

main_structural_directories:
  description: {_("Directories where structural files are placed")}
  type: unix_filename
  alternative_name: m
  params:
     allow_relative: True
     test_existence: True
  multi: true
  disabled:
    jinja: >-
      {{% if 'directory' not in _.step.structural %}}
        directory is not in _.step.structural
      {{% endif %}}
      {{% if cli is defined and cli.versions is defined and cli.versions %}}
        cli.versions is specified
      {{% endif %}}

sort_structural_files_all:
  description: {_("Sort structural from differents directories")}
  default: false
  disabled:
    jinja: >-
      {{% if 'directory' not in _.step.structural %}}
        directory is not in _.step.structural
      {{% endif %}}

isolated_namespace:
  description: {_("Namespaces are isolated")}
  default: true
  disabled:
    jinja: >-
      {{{{ 'directory' not in _.step.structural and 'string' not in _.step.structural }}}}
    return_type: boolean
    description: {_('directory or string is not in "_.step.structural" or "_.main_namespace" is not set')}

extra_namespaces:
  description: {_("Extra namespaces")}
  type: sequence
  disabled:
    jinja: >-
      {{{{ ('directory' not in _.step.structural and 'string' not in _.step.structural) or not _.main_namespace }}}}
    return_type: boolean
    description: directory is not in _.step.structural or main_namespace is not set

  names:
    description: {_("Extra namespace name")}
    alternative_name: xn
    multi: true
    mandatory: false

  directories:
    description: {_("Directories where extra structural files are placed")}
    alternative_name: xd
    type: unix_filename
    params:
      allow_relative: true
      test_existence: true
    multi: true
    disabled:
      jinja: >-
        {{{{ 'directory' not in __.step.structural }}}}
      return_type: boolean
      description: {_('directory is not in "__.step.structural"')}
"""
    return {
        "name": "directory",
        "process": "structural",
        "options": options,
        "level": 5,
    }


__all__ = "get_rougail_config"
