Compare commits

..

No commits in common. "0.2.0a24" and "main" have entirely different histories.

24 changed files with 64 additions and 638 deletions

View file

@ -1,167 +1,3 @@
## 0.2.0a24 (2025-10-10)
### Feat
- use rougail-user-data-commandline and mix config use data
### Fix
- remove force_apply_user_data support
## 0.2.0a23 (2025-10-03)
### Fix
- config in read_only mode is asked
## 0.2.0a22 (2025-10-02)
### Feat
- limit warning when asked
## 0.2.0a21 (2025-09-29)
### Feat
- add cli.read_write option
## 0.2.0a20 (2025-09-22)
### Fix
- dictionary => structure
## 0.2.0a19 (2025-09-03)
### Fix
- do now set modified option in second round
## 0.2.0a18 (2025-05-14)
### Feat
- able to lad config_file name from environement variable
- loads user datas before and after cli params
## 0.2.0a17 (2025-05-12)
### Fix
- upgrade translation
- black
## 0.2.0a16 (2025-05-09)
### Fix
- description
## 0.2.0a15 (2025-05-05)
### Fix
- do not raise if warning in cli
## 0.2.0a14 (2025-05-02)
### Fix
- do not force use_data usage
## 0.2.0a13 (2025-04-30)
### Fix
- add first test + remove add_extra_options option in tiramisu-cmdline-parser
- remove negative_description support
- display user-data instead of user_data in version
## 0.2.0a12 (2025-04-09)
### Fix
- version
## 0.2.0a11 (2025-03-31)
### Fix
- translation
## 0.2.0a10 (2025-03-31)
### Fix
- access to cli.config_file variable with commandline
## 0.2.0a9 (2025-03-31)
### Feat
- cli loads .rougailcli.yml file
## 0.2.0a8 (2025-02-17)
### Fix
- add config.py file
## 0.2.0a7 (2025-02-17)
### Fix
- better error support
## 0.2.0a6 (2025-02-10)
### Feat
- return 1 if output has problems
## 0.2.0a5 (2025-02-05)
### Feat
- user_data can be loaded after other plugins
## 0.2.0a4 (2025-01-04)
### Fix
- add and remove not_for_commandline property
## 0.2.0a3 (2025-01-04)
### Fix
- remove upgrade feature (now in formatter project) + better support of not_for_commandline feature
## 0.2.0a2 (2024-12-11)
### Fix
- user_data and output are not plugins
## 0.2.0a1 (2024-11-28)
### Fix
- separation between run and print function
## 0.2.0a0 (2024-11-27)
### Feat
- load config from environment if rougail-user-data-environment is installed
### Fix
- translation is not mandatory
## 0.1.1 (2024-11-06)
## 0.1.1rc0 (2024-11-06) ## 0.1.1rc0 (2024-11-06)
### Fix ### Fix

Binary file not shown.

View file

@ -5,8 +5,8 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"POT-Creation-Date: 2025-05-14 08:22+0200\n" "POT-Creation-Date: 2024-10-31 09:57+0100\n"
"PO-Revision-Date: 2025-05-14 08:22+0200\n" "PO-Revision-Date: 2024-10-31 10:00+0100\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
"Language: fr\n" "Language: fr\n"
@ -16,40 +16,14 @@ msgstr ""
"Generated-By: pygettext.py 1.5\n" "Generated-By: pygettext.py 1.5\n"
"X-Generator: Poedit 3.5\n" "X-Generator: Poedit 3.5\n"
#: src/rougail/cli/__main__.py:170 #: src/rougail/cli/__main__.py:43
msgid "cannot find \"user_data\" module \"{0}\"" msgid "cannot find \"user_data\" module \"{0}\""
msgstr "ne peut trouve le module \"user_data\" \"{0}\"" msgstr "ne peut trouve le module \"user_data\" \"{0}\""
#: src/rougail/cli/__main__.py:214 #: src/rougail/cli/__main__.py:56
msgid "cannot find cli file for \"output_name\" module \"{0}\"" msgid "cannot find cli file for \"output_name\" module \"{0}\""
msgstr "ne peut trouve le fichier cli pour le module \"output_name\" \"{0}\"" msgstr "ne peut trouve le fichier cli pour le module \"output_name\" \"{0}\""
#: src/rougail/cli/__main__.py:240 #: src/rougail/cli/__main__.py:69
msgid "ERROR: {0}" msgid "ERROR: {0}"
msgstr "ERREUR : {0}" msgstr "ERREUR : {0}"
#: src/rougail/cli/config.py:28
msgid "Command line options"
msgstr "Options de la ligne de commande"
#: src/rougail/cli/config.py:31
msgid "Loads command line parameters from a file"
msgstr "Charger les paramètres de la ligne de commande depuis un fichier"
#: src/rougail/cli/config.py:39
msgid "Displays debug informations"
msgstr "Afficher les informations de debug"
#: src/rougail/cli/config.py:43
msgid "Displays command line option warnings informations"
msgstr "Afficher les avertissements de chargement des options de la ligne de commande"
#: src/rougail/cli/config.py:47
msgid "Displays Rougail version and all its components"
msgstr "Afficher la version de Rougail et de tous ces composants"
#~ msgid "do not display debug informations"
#~ msgstr "ne pas afficher les informations de debug"
#~ msgid "do not display rougail version and all componants"
#~ msgstr "ne pas afficher la version de rougail et de tous ces composants"

View file

@ -5,7 +5,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2025-05-14 08:25+0200\n" "POT-Creation-Date: 2024-10-31 19:17+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -15,35 +15,15 @@ msgstr ""
"Generated-By: pygettext.py 1.5\n" "Generated-By: pygettext.py 1.5\n"
#: src/rougail/cli/__main__.py:170 #: src/rougail/cli/__main__.py:63
msgid "cannot find \"user_data\" module \"{0}\"" msgid "cannot find \"user_data\" module \"{0}\""
msgstr "" msgstr ""
#: src/rougail/cli/__main__.py:214 #: src/rougail/cli/__main__.py:76
msgid "cannot find cli file for \"output_name\" module \"{0}\"" msgid "cannot find cli file for \"output_name\" module \"{0}\""
msgstr "" msgstr ""
#: src/rougail/cli/__main__.py:240 #: src/rougail/cli/__main__.py:89
msgid "ERROR: {0}" msgid "ERROR: {0}"
msgstr "" msgstr ""
#: src/rougail/cli/config.py:28
msgid "Command line options"
msgstr ""
#: src/rougail/cli/config.py:31
msgid "Loads command line parameters from a file"
msgstr ""
#: src/rougail/cli/config.py:39
msgid "Displays debug informations"
msgstr ""
#: src/rougail/cli/config.py:43
msgid "Displays command line option warnings informations"
msgstr ""
#: src/rougail/cli/config.py:47
msgid "Displays Rougail version and all its components"
msgstr ""

View file

@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
[project] [project]
name = "rougail.cli" name = "rougail.cli"
version = "0.2.0a24" version = "0.1.1"
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}] authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
readme = "README.md" readme = "README.md"
description = "CLI for Rougail" description = "CLI for Rougail"
@ -13,10 +13,11 @@ license = {file = "LICENSE"}
classifiers = [ classifiers = [
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)", "License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
"Programming Language :: Python", "Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",
"Operating System :: OS Independent", "Operating System :: OS Independent",
"Natural Language :: English", "Natural Language :: English",
@ -25,7 +26,7 @@ classifiers = [
] ]
dependencies = [ dependencies = [
"rougail >= 1.1,<2", "rougail >= 1.1,<2",
"rougail-user-data-commandline", "tiramisu_cmdline_parser >= 0.6,<1",
] ]
[project.scripts] [project.scripts]
@ -39,9 +40,5 @@ name = "cz_conventional_commits"
tag_format = "$version" tag_format = "$version"
version_scheme = "pep440" version_scheme = "pep440"
version_provider = "pep621" version_provider = "pep621"
version_files = [ #update_changelog_on_bump = true
"src/rougail/cli/__version__.py",
"pyproject.toml:version"
]
update_changelog_on_bump = true
changelog_merge_prerelease = true changelog_merge_prerelease = true

View file

@ -1,6 +1,6 @@
""" """
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2024-2025 Copyright (C) 2024
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -15,5 +15,3 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Mtools. If not, see <http://www.gnu.org/licenses/>. along with Mtools. If not, see <http://www.gnu.org/licenses/>.
""" """
from .__version__ import __version__

View file

@ -1,6 +1,6 @@
""" """
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2024-2025 Copyright (C) 2024
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -16,233 +16,93 @@ You should have received a copy of the GNU General Public License
along with Mtools. If not, see <http://www.gnu.org/licenses/>. along with Mtools. If not, see <http://www.gnu.org/licenses/>.
""" """
import os
from warnings import warn, filterwarnings
from pathlib import Path
from sys import exit
from tiramisu_cmdline_parser import TiramisuCmdlineParser from tiramisu_cmdline_parser import TiramisuCmdlineParser
from tiramisu.error import PropertiesOptionError
from tiramisu import Config from tiramisu import Config
from pathlib import Path
from rougail import Rougail from rougail import Rougail, PropertiesOptionError
from rougail.config import get_rougail_config from rougail.config import get_rougail_config
from rougail.update import RougailUpgrade
from rougail.utils import load_modules from rougail.utils import load_modules
from rougail.user_datas import UserDatas
from rougail.error import RougailWarning
from rougail.user_data_commandline import RougailUserDataCommandline
try:
from rougail.user_data_yaml import RougailUserDataYaml
except ImportError:
RougailUserDataYaml = None
try:
from rougail.user_data_environment import RougailUserDataEnvironment
except ImportError:
RougailUserDataEnvironment = None
from .i18n import _ from .i18n import _
ENV_PREFIX = "ROUGAILCLI" def _main():
def _main(arguments, do_not_print):
global print_traceback
rougailconfig = get_rougail_config( rougailconfig = get_rougail_config(
backward_compatibility=False, add_extra_options=False backward_compatibility=False, add_extra_options=False
) )
rougailconfig.generate_config() cmd_config = rougailconfig.config
cmd_config = load_cmd_user_datas(rougailconfig.config, arguments)
print_traceback = rougailconfig["cli.debug"]
if rougailconfig["cli.versions"]:
versions = display_version(cmd_config)
if do_not_print:
return list(versions)
for version in versions:
print(version)
else:
manage_warnings(rougailconfig["cli.warnings"])
config, err_warn = load_user_datas(rougailconfig)
output = get_output(rougailconfig, config, err_warn)
if do_not_print:
return output.run()
ret = output.print()
if ret is False:
exit(1)
def load_cmd_user_datas(cmd_config, arguments):
origin_prop = cmd_config.property.default("read_write", "append")
cmd_config.property.setdefault(
frozenset(origin_prop | {"not_for_commandline"}), "read_write", "append"
)
cmd_config.property.read_write() cmd_config.property.read_write()
cmd_user_datas = [] cmd_config.property.add("not_for_commandline")
if RougailUserDataYaml:
config_file = os.environ.pop(f"{ENV_PREFIX}_CLI.CONFIG_FILE", None)
if not config_file:
config_file = cmd_config.forcepermissive.option("cli.config_file").value.get()
if Path(config_file).is_file():
fake_rougail_config = {
"step.user_data": ["yaml"],
"yaml.filename": [config_file],
"yaml.file_with_secrets": "all",
}
cmd_user_datas.extend(
RougailUserDataYaml(cmd_config,
rougailconfig=fake_rougail_config,
).run()
)
if RougailUserDataEnvironment:
fake_rougail_config = {
"step.user_data": ["environment"],
"environment.default_environment_name": ENV_PREFIX,
}
cmd_user_datas.extend(
RougailUserDataEnvironment(
cmd_config,
rougailconfig=fake_rougail_config,
).run()
)
fake_rougail_config = {
"step.user_data": ["commandline"],
}
cmd_user_datas.extend(
RougailUserDataCommandline(cmd_config,
rougailconfig=fake_rougail_config,
short_name_max_len=2,
arguments=arguments,
).run()
)
user_data = UserDatas(cmd_config).user_datas(cmd_user_datas)
if user_data["warnings"] and cmd_config.option("cli.warnings").value.get():
for warning in user_data["warnings"]:
warn(warning)
# replays to display errors if needed
parser = TiramisuCmdlineParser( parser = TiramisuCmdlineParser(
cmd_config, cmd_config,
add_extra_options=False,
short_name_max_len=2, short_name_max_len=2,
) )
if not cmd_config.option("cli.versions").value.get(): parser.parse_args()
parser.parse_args(arguments)
if user_data["errors"]:
raise Exception(user_data["errors"][0])
cmd_config.property.setdefault(origin_prop, "read_write", "append")
cmd_config.property.remove("not_for_commandline") cmd_config.property.remove("not_for_commandline")
cmd_config.property.read_only() cmd_config.property.read_only()
return cmd_config if rougailconfig["upgrade"]:
RougailUpgrade(rougailconfig=rougailconfig).run()
return
def display_version(cmd_config):
versions = []
from tiramisu import __version__
yield(f"tiramisu: {__version__}")
from tiramisu_cmdline_parser import __version__
yield(f"tiramisu-cmdline-parser: {__version__}")
from rougail import __version__
yield(f"rougail: {__version__}")
from . import __version__
yield(f"rougail-cli: {__version__}")
for step in ["structural", "user_data", "output"]:
display_step = step.replace("_", "-")
for step_name in sorted(cmd_config.unrestraint.option(f"step.{step}").value.list()):
path = (
Path(__file__).parent.parent
/ (step + "_" + step_name)
/ "__init__.py"
)
if path.is_file():
try:
module = load_modules(
"rougail." + step + "_" + step_name, str(path)
)
yield(
f"rougail-{display_step}-{step_name}: {module.__version__}"
)
except Exception as err:
pass
def manage_warnings(warnings):
if not warnings:
filterwarnings("ignore", category=DeprecationWarning)
filterwarnings("ignore", category=RougailWarning)
else:
filterwarnings("default", category=DeprecationWarning)
filterwarnings("default", category=RougailWarning)
def load_user_datas(rougailconfig):
try: try:
user_data_names = rougailconfig["step.user_data"] user_data_names = rougailconfig["step.user_data"]
except PropertiesOptionError: except PropertiesOptionError:
user_data_names = [] user_data_names = []
output_name = rougailconfig["step.output"]
# structural # structural
if rougailconfig["cli.load_config"]: rougail = Rougail(rougailconfig)
rougail = Rougail(rougailconfig)
config = rougail.run()
config.property.read_write()
else:
config = None
# data user
user_datas = []
for user_data_name in user_data_names: for user_data_name in user_data_names:
path = ( rougail.converted.plugins.append("user_data_" + user_data_name)
Path(__file__).parent.parent rougail.converted.plugins.append("output_" + output_name)
/ ("user_data_" + user_data_name) config = rougail.get_config()
/ "__init__.py" # data user
) if not user_data_names:
if not path.is_file(): user_datas = None
raise Exception( else:
_('cannot find "user_data" module "{0}"').format(user_data_name) config.property.read_write()
user_datas = []
for user_data_name in user_data_names:
path = (
Path(__file__).parent.parent
/ ("user_data_" + user_data_name)
/ "__init__.py"
)
if not path.is_file():
raise Exception(
_('cannot find "user_data" module "{0}"').format(user_data_name)
)
module = load_modules("rougail.user_data_" + user_data_name, str(path))
user_datas.extend(
module.RougailUserData(
config,
rougailconfig=rougailconfig,
).run()
) )
module = load_modules("rougail.user_data_" + user_data_name, str(path))
user_datas.extend(
module.RougailUserData(
config,
rougailconfig=rougailconfig,
).run()
)
if user_datas: if user_datas:
err_warn = rougail.user_datas(user_datas) err_warn = rougail.user_datas(user_datas)
else: else:
err_warn = {"errors": [], "warnings": []} err_warn = {"errors": [], "warnings": []}
return config, err_warn
def get_output(rougailconfig, config, err_warn):
# output # output
if config and (not rougailconfig["cli.load_config"] or not rougailconfig["cli.read_write"]): config.property.read_only()
config.property.read_only()
output_name = rougailconfig["step.output"]
path = Path(__file__).parent.parent / ("output_" + output_name) / "__init__.py" path = Path(__file__).parent.parent / ("output_" + output_name) / "__init__.py"
if not path.is_file(): if not path.is_file():
raise Exception( raise Exception(
_('cannot find cli file for "output_name" module "{0}"').format(output_name) _('cannot find cli file for "output_name" module "{0}"').format(output_name)
) )
module = load_modules("rougail.output_" + output_name, str(path)) module = load_modules("rougail.output_" + output_name, str(path))
output = module.RougailOutput( module.RougailOutput(
config=config, config=config,
rougailconfig=rougailconfig, rougailconfig=rougailconfig,
user_data_errors=err_warn["errors"], user_data_errors=err_warn["errors"],
user_data_warnings=err_warn["warnings"], user_data_warnings=err_warn["warnings"],
) ).run()
return output
def main(arguments=None, do_not_print=False): def main():
global print_traceback
print_traceback = True
try: try:
return _main(arguments, do_not_print) _main()
except Exception as err: except Exception as err:
if print_traceback: print(_("ERROR: {0}").format(err))
import traceback exit(1)
traceback.print_exc()
exit(_("ERROR: {0}").format(err))

View file

@ -1 +0,0 @@
__version__ = "0.2.0a24"

View file

@ -1,53 +0,0 @@
"""
Silique (https://www.silique.fr)
Copyright (C) 2025
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 .i18n import _
def get_rougail_config(
*,
backward_compatibility: bool = True, # pylint: disable=unused-argument
) -> dict:
options = f"""
cli:
description: {_('Command line options')}
config_file:
description: {_('Loads command line parameters from a file')}
type: unix_filename
commandline: false
params:
allow_relative: true
default: .rougailcli.yml
debug: false # {_('Displays debug informations')}
warnings: true # {_('Displays command line option warnings informations')}
versions: false # {_('Displays Rougail version and all its components')}
load_config:
default: true
hidden: true
read_write: false # {_('Configuration in output step is in read_write mode')}
"""
return {
"options": options,
"process": None,
}

View file

@ -1,6 +1,6 @@
"""Internationalisation utilities """Internationalisation utilities
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2024-2025 Copyright (C) 2024
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -19,6 +19,6 @@ along with Mtools. If not, see <http://www.gnu.org/licenses/>.
from gettext import translation from gettext import translation
from pathlib import Path from pathlib import Path
t = translation("rougail_cli", str(Path(__file__).parent / "locale"), fallback=True) t = translation("rougail_cli", str(Path(__file__).parent / "locale"))
_ = t.gettext _ = t.gettext

View file

@ -1,5 +0,0 @@
╭─────── Caption ────────╮
│ Variable Default value │
╰────────────────────────╯
Variables:
┗━━ 📓 a description: my_value

View file

@ -1,4 +0,0 @@
---
version: 1.1
my_variable: my_value # a description

View file

@ -1,7 +0,0 @@
---
main_structural_directories:
- structures
step:
output: doc
doc:
output_format: json

View file

@ -1 +0,0 @@
"\u250f\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2533\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n\u2503\u001b[1m \u001b[0m\u001b[1mVariable \u001b[0m\u001b[1m \u001b[0m\u2503\u001b[1m \u001b[0m\u001b[1mDescription \u001b[0m\u001b[1m \u001b[0m\u2503\n\u2521\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2547\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2529\n\u2502 \u001b[1mmy_variable\u001b[0m \u2502 A description. \u2502\n\u2502 \u001b[1;7m string \u001b[0m \u001b[1;7m mandatory \u001b[0m \u2502 \u001b[1mDefault\u001b[0m: my_value \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n"

View file

@ -1,7 +0,0 @@
---
main_structural_directories:
- structures
step:
output: doc
doc:
output_format: console

View file

@ -1 +0,0 @@
"[cols=\"1a,1a\"]\n|====\n| Variable | Description \n| \n\n**my_variable** +\n`https://rougail.readthedocs.io/en/latest/variable.html#variables-types[string]` `mandatory` | \nA description. +\n**Default**: my_value \n|====\n\n"

View file

@ -1,6 +0,0 @@
---
main_structural_directories:
- structures
doc:
output_format: console

View file

@ -1,4 +0,0 @@
---
version: 1.1
my_variable: my_value # a description

View file

@ -1 +0,0 @@
"{\n \"my_variable\": {\n \"type\": \"variable\",\n \"default\": {\n \"name\": \"Default\",\n \"values\": \"my_value\"\n },\n \"properties\": [\n {\n \"type\": \"type\",\n \"name\": \"string\"\n },\n {\n \"type\": \"property\",\n \"name\": \"mandatory\"\n }\n ],\n \"paths\": [\n \"my_variable\"\n ],\n \"names\": [\n \"my_variable\"\n ],\n \"descriptions\": [\n \"A description.\"\n ]\n }\n}"

View file

@ -1,3 +0,0 @@
---
doc:
output_format: json

View file

@ -1,4 +0,0 @@
---
version: 1.1
my_variable: my_value # a description

View file

@ -1 +0,0 @@
"{\n \"my_variable\": {\n \"type\": \"variable\",\n \"default\": {\n \"name\": \"Default\",\n \"values\": \"my_value\"\n },\n \"properties\": [\n {\n \"type\": \"type\",\n \"name\": \"string\"\n },\n {\n \"type\": \"property\",\n \"name\": \"mandatory\"\n }\n ],\n \"paths\": [\n \"my_variable\"\n ],\n \"names\": [\n \"my_variable\"\n ],\n \"descriptions\": [\n \"A description.\"\n ]\n }\n}"

View file

@ -1,121 +0,0 @@
import os
from pathlib import Path
from contextlib import chdir
from json import dumps, loads
from rougail.cli.__main__ import main
test_dir = Path(__file__).parent
def test_cli():
with chdir(test_dir / 'cli'):
ret = main(['--main_structural_directories', 'structures'], do_not_print=True)
filename = Path('result.txt')
if not filename.is_file():
with filename.open('w') as fh:
fh.write(ret[1])
with filename.open() as fh:
data = fh.read()
assert ret == (True, data)
def test_cli_boolean():
with chdir(test_dir / 'cli'):
ret = main(['--main_structural_directories', 'structures', '--console.mandatory'], do_not_print=True)
filename = Path('result.txt')
if not filename.is_file():
with filename.open('w') as fh:
fh.write(ret[1])
with filename.open() as fh:
data = fh.read()
assert ret == (True, data)
def test_cli_boolean_no():
with chdir(test_dir / 'cli'):
ret = main(['--main_structural_directories', 'structures', '--console.no-mandatory'], do_not_print=True)
filename = Path('result.txt')
if not filename.is_file():
with filename.open('w') as fh:
fh.write(ret[1])
with filename.open() as fh:
data = fh.read()
assert ret == (True, data)
def test_cli_version():
with chdir(test_dir / 'cli'):
ret = main(['--cli.version'], do_not_print=True)
ret = [r.rsplit(': ', 1)[0] for r in ret]
filename = Path('versions.txt')
if not filename.is_file():
with filename.open('w') as fh:
fh.write(dumps(ret))
with filename.open() as fh:
data = loads(fh.read())
assert ret == data
def test_cli_version_user_data_disabled():
with chdir(test_dir / 'cli'):
ret = main(['--cli.version', '--step.output', 'doc'], do_not_print=True)
ret = [r.rsplit(': ', 1)[0] for r in ret]
filename = Path('versions.txt')
if not filename.is_file():
with filename.open('w') as fh:
fh.write(dumps(ret))
with filename.open() as fh:
data = loads(fh.read())
assert ret == data
def test_cli_version_user_data_disabled_2():
with chdir(test_dir / 'second_step'):
ret = main(['--main_structural_directories', 'structures', '--step.output', 'doc'], do_not_print=True)
filename = Path('yaml.txt')
if not filename.is_file():
with filename.open('w') as fh:
fh.write(dumps(ret[1]))
with filename.open() as fh:
data = loads(fh.read())
assert ret == (True, data)
def test_cli_rougailcli():
with chdir(test_dir / 'rougailcli_file'):
ret = main([], do_not_print=True)
filename = Path('yaml.txt')
if not filename.is_file():
with filename.open('w') as fh:
fh.write(dumps(ret[1]))
with filename.open() as fh:
data = loads(fh.read())
assert ret == (True, data)
def test_cli_alt_rougailcli():
with chdir(test_dir / 'rougailcli_file'):
os.environ["ROUGAILCLI_CLI.CONFIG_FILE"] = 'alt_rougailcli.yml'
ret = main([], do_not_print=True)
filename = Path('alt_console.txt')
if not filename.is_file():
with filename.open('w') as fh:
fh.write(dumps(ret[1]))
with filename.open() as fh:
data = loads(fh.read())
assert ret == (True, data)
def test_cli_rougailcli_mix():
with chdir(test_dir / 'rougailcli_file'):
os.environ["ROUGAILCLI_CLI.CONFIG_FILE"] = 'mix_rougailcli.yml'
ret = main(["-o", "doc", "--doc.output_format", "asciidoc"], do_not_print=True)
filename = Path('mix_console.txt')
if not filename.is_file():
with filename.open('w') as fh:
fh.write(dumps(ret[1]))
with filename.open() as fh:
data = loads(fh.read())
assert ret == (True, data)