Compare commits
28 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f5f85ba79f | |||
| cf0fc37aef | |||
| 8ecc0e0f55 | |||
| 0f1e1b9ea5 | |||
| 1036ccb358 | |||
| 5327ff1917 | |||
| c31652256f | |||
| 8c924a7cba | |||
| 3f2920f37c | |||
| 0010c9cf07 | |||
| fb7c3c3346 | |||
| e6582d6d9d | |||
| 5cfa351e67 | |||
| e9b1ab5f85 | |||
| 95da29454a | |||
| a530ff33d6 | |||
| dcbe1a99d6 | |||
| c0d103f2e8 | |||
| e87bcbd4c8 | |||
| 703b1ce70e | |||
| 60ee2a6feb | |||
| 6feebea664 | |||
| b5c845f90c | |||
| c79975c5df | |||
| 52cbfc1f15 | |||
| e62797c79f | |||
| 8073ef9bc1 | |||
| ea0076279c |
11 changed files with 295 additions and 27 deletions
84
CHANGELOG.md
84
CHANGELOG.md
|
|
@ -1,3 +1,87 @@
|
|||
## 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)
|
||||
|
||||
### Fix
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -5,8 +5,8 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"POT-Creation-Date: 2024-10-31 09:57+0100\n"
|
||||
"PO-Revision-Date: 2024-10-31 10:00+0100\n"
|
||||
"POT-Creation-Date: 2025-04-09 21:21+0200\n"
|
||||
"PO-Revision-Date: 2025-04-09 21:22+0200\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: fr\n"
|
||||
|
|
@ -16,14 +16,38 @@ msgstr ""
|
|||
"Generated-By: pygettext.py 1.5\n"
|
||||
"X-Generator: Poedit 3.5\n"
|
||||
|
||||
#: src/rougail/cli/__main__.py:43
|
||||
#: src/rougail/cli/__main__.py:125
|
||||
msgid "cannot find \"user_data\" module \"{0}\""
|
||||
msgstr "ne peut trouve le module \"user_data\" \"{0}\""
|
||||
|
||||
#: src/rougail/cli/__main__.py:56
|
||||
#: src/rougail/cli/__main__.py:162
|
||||
msgid "cannot find cli file for \"output_name\" module \"{0}\""
|
||||
msgstr "ne peut trouve le fichier cli pour le module \"output_name\" \"{0}\""
|
||||
|
||||
#: src/rougail/cli/__main__.py:69
|
||||
#: src/rougail/cli/__main__.py:184
|
||||
msgid "ERROR: {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 "charge les paramètres de la ligne de commande depuis un fichier"
|
||||
|
||||
#: src/rougail/cli/config.py:39
|
||||
msgid "display debug informations"
|
||||
msgstr "affiche les informations de debug"
|
||||
|
||||
#: src/rougail/cli/config.py:40
|
||||
msgid "do not display debug informations"
|
||||
msgstr "ne pas afficher les informations de debug"
|
||||
|
||||
#: src/rougail/cli/config.py:44
|
||||
msgid "display rougail version and all componants"
|
||||
msgstr "afficher la version de rougail et de tous ces composants"
|
||||
|
||||
#: src/rougail/cli/config.py:45
|
||||
msgid "do not display rougail version and all componants"
|
||||
msgstr "ne pas afficher la version de rougail et de tous ces composants"
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2024-10-31 19:17+0100\n"
|
||||
"POT-Creation-Date: 2025-04-09 21:22+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
|
@ -15,15 +15,39 @@ msgstr ""
|
|||
"Generated-By: pygettext.py 1.5\n"
|
||||
|
||||
|
||||
#: src/rougail/cli/__main__.py:63
|
||||
#: src/rougail/cli/__main__.py:125
|
||||
msgid "cannot find \"user_data\" module \"{0}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/__main__.py:76
|
||||
#: src/rougail/cli/__main__.py:162
|
||||
msgid "cannot find cli file for \"output_name\" module \"{0}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/__main__.py:89
|
||||
#: src/rougail/cli/__main__.py:184
|
||||
msgid "ERROR: {0}"
|
||||
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 "display debug informations"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/config.py:40
|
||||
msgid "do not display debug informations"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/config.py:44
|
||||
msgid "display rougail version and all componants"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/config.py:45
|
||||
msgid "do not display rougail version and all componants"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
|
|||
|
||||
[project]
|
||||
name = "rougail.cli"
|
||||
version = "0.1.1"
|
||||
version = "0.2.0a12"
|
||||
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
|
||||
readme = "README.md"
|
||||
description = "CLI for Rougail"
|
||||
|
|
@ -18,6 +18,8 @@ classifiers = [
|
|||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
"Programming Language :: Python :: 3.13",
|
||||
"Programming Language :: Python :: 3.14",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Operating System :: OS Independent",
|
||||
"Natural Language :: English",
|
||||
|
|
@ -40,5 +42,9 @@ name = "cz_conventional_commits"
|
|||
tag_format = "$version"
|
||||
version_scheme = "pep440"
|
||||
version_provider = "pep621"
|
||||
#update_changelog_on_bump = true
|
||||
version_files = [
|
||||
"src/rougail/cli/__version__.py",
|
||||
"pyproject.toml:version"
|
||||
]
|
||||
update_changelog_on_bump = true
|
||||
changelog_merge_prerelease = true
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"""
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2024
|
||||
Copyright (C) 2024-2025
|
||||
|
||||
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
|
||||
|
|
@ -15,3 +15,4 @@ GNU General Public License for more details.
|
|||
You should have received a copy of the GNU General Public License
|
||||
along with Mtools. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
from .__version__ import __version__
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"""
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2024
|
||||
Copyright (C) 2024-2025
|
||||
|
||||
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
|
||||
|
|
@ -17,13 +17,22 @@ along with Mtools. If not, see <http://www.gnu.org/licenses/>.
|
|||
"""
|
||||
|
||||
from tiramisu_cmdline_parser import TiramisuCmdlineParser
|
||||
from tiramisu.error import PropertiesOptionError
|
||||
from tiramisu import Config
|
||||
from pathlib import Path
|
||||
|
||||
from rougail import Rougail, PropertiesOptionError
|
||||
from rougail import Rougail
|
||||
from rougail.config import get_rougail_config
|
||||
from rougail.update import RougailUpgrade
|
||||
from rougail.utils import load_modules
|
||||
from rougail.user_datas import UserDatas
|
||||
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 _
|
||||
|
||||
|
|
@ -32,31 +41,73 @@ def _main():
|
|||
rougailconfig = get_rougail_config(
|
||||
backward_compatibility=False, add_extra_options=False
|
||||
)
|
||||
rougailconfig.generate_config()
|
||||
cmd_config = rougailconfig.config
|
||||
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.add("not_for_commandline")
|
||||
fake_rougail_config = {'step.user_data': [],}
|
||||
fake_user_datas = []
|
||||
if RougailUserDataYaml:
|
||||
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',
|
||||
}
|
||||
fake_user_datas.extend(RougailUserDataYaml(cmd_config, rougailconfig=fake_rougail_config).run())
|
||||
if RougailUserDataEnvironment:
|
||||
fake_rougail_config = {'step.user_data': 'environment',
|
||||
'environment.default_environment_name': 'ROUGAILCLI',
|
||||
}
|
||||
fake_user_datas.extend(RougailUserDataEnvironment(cmd_config, rougailconfig=fake_rougail_config).run())
|
||||
if fake_user_datas:
|
||||
user_data = UserDatas(cmd_config).user_datas(fake_user_datas)
|
||||
if user_data["errors"]:
|
||||
raise Exception(user_data["errors"][0])
|
||||
if user_data["warnings"]:
|
||||
raise Exception(user_data["warnings"][0])
|
||||
parser = TiramisuCmdlineParser(
|
||||
cmd_config,
|
||||
add_extra_options=False,
|
||||
short_name_max_len=2,
|
||||
)
|
||||
parser.parse_args()
|
||||
global print_traceback
|
||||
print_traceback = rougailconfig["cli.debug"]
|
||||
cmd_config.property.setdefault(origin_prop, 'read_write', 'append')
|
||||
cmd_config.property.remove("not_for_commandline")
|
||||
cmd_config.property.read_only()
|
||||
if rougailconfig["upgrade"]:
|
||||
RougailUpgrade(rougailconfig=rougailconfig).run()
|
||||
if rougailconfig['cli.versions']:
|
||||
from tiramisu import __version__
|
||||
print(f'tiramisu: {__version__}')
|
||||
from tiramisu_cmdline_parser import __version__
|
||||
print(f'tiramisu-cmdline-parser: {__version__}')
|
||||
from rougail import __version__
|
||||
print(f'rougail: {__version__}')
|
||||
from . import __version__
|
||||
print(f'rougail-cli: {__version__}')
|
||||
for step in ['structural', 'user_data', 'output']:
|
||||
for step_name in sorted(cmd_config.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))
|
||||
print(f'rougail-{step}-{step_name}: {module.__version__}')
|
||||
except Exception as err:
|
||||
pass
|
||||
return
|
||||
try:
|
||||
user_data_names = rougailconfig["step.user_data"]
|
||||
except PropertiesOptionError:
|
||||
user_data_names = []
|
||||
output_name = rougailconfig["step.output"]
|
||||
# structural
|
||||
rougail = Rougail(rougailconfig)
|
||||
for user_data_name in user_data_names:
|
||||
rougail.converted.plugins.append("user_data_" + user_data_name)
|
||||
rougail.converted.plugins.append("output_" + output_name)
|
||||
config = rougail.get_config()
|
||||
config = rougail.run()
|
||||
# data user
|
||||
if not user_data_names:
|
||||
user_datas = None
|
||||
|
|
@ -74,6 +125,8 @@ def _main():
|
|||
_('cannot find "user_data" module "{0}"').format(user_data_name)
|
||||
)
|
||||
module = load_modules("rougail.user_data_" + user_data_name, str(path))
|
||||
if hasattr(module.RougailUserData, 'force_apply_user_data') and module.RougailUserData.force_apply_user_data is True:
|
||||
continue
|
||||
user_datas.extend(
|
||||
module.RougailUserData(
|
||||
config,
|
||||
|
|
@ -84,25 +137,49 @@ def _main():
|
|||
err_warn = rougail.user_datas(user_datas)
|
||||
else:
|
||||
err_warn = {"errors": [], "warnings": []}
|
||||
if user_data_names:
|
||||
config.property.read_write()
|
||||
for user_data_name in user_data_names:
|
||||
path = (
|
||||
Path(__file__).parent.parent
|
||||
/ ("user_data_" + user_data_name)
|
||||
/ "__init__.py"
|
||||
)
|
||||
module = load_modules("rougail.user_data_" + user_data_name, str(path))
|
||||
if hasattr(module.RougailUserData, 'force_apply_user_data') and module.RougailUserData.force_apply_user_data is True:
|
||||
ret = module.RougailUserData(
|
||||
config,
|
||||
rougailconfig=rougailconfig,
|
||||
).run()
|
||||
err_warn["errors"].extend(ret["errors"])
|
||||
err_warn["warnings"].extend(ret["warnings"])
|
||||
# output
|
||||
config.property.read_only()
|
||||
output_name = rougailconfig["step.output"]
|
||||
path = Path(__file__).parent.parent / ("output_" + output_name) / "__init__.py"
|
||||
if not path.is_file():
|
||||
raise Exception(
|
||||
_('cannot find cli file for "output_name" module "{0}"').format(output_name)
|
||||
)
|
||||
module = load_modules("rougail.output_" + output_name, str(path))
|
||||
module.RougailOutput(
|
||||
ret = module.RougailOutput(
|
||||
config=config,
|
||||
rougailconfig=rougailconfig,
|
||||
user_data_errors=err_warn["errors"],
|
||||
user_data_warnings=err_warn["warnings"],
|
||||
).run()
|
||||
).print()
|
||||
if ret is False:
|
||||
exit(1)
|
||||
|
||||
|
||||
def main():
|
||||
global print_traceback
|
||||
print_traceback = True
|
||||
try:
|
||||
_main()
|
||||
except Exception as err:
|
||||
if print_traceback:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
print(_("ERROR: {0}").format(err))
|
||||
exit(1)
|
||||
|
|
|
|||
1
src/rougail/cli/__version__.py
Normal file
1
src/rougail/cli/__version__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
__version__ = "0.2.0a12"
|
||||
51
src/rougail/cli/config.py
Normal file
51
src/rougail/cli/config.py
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
"""
|
||||
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:
|
||||
description: {_('display debug informations')}
|
||||
negative_description: {_('do not display debug informations')}
|
||||
default: false
|
||||
|
||||
versions:
|
||||
description: {_('display rougail version and all componants')}
|
||||
negative_description: {_('do not display rougail version and all componants')}
|
||||
default: false
|
||||
"""
|
||||
return {
|
||||
"options": options,
|
||||
"process": None,
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
"""Internationalisation utilities
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2024
|
||||
Copyright (C) 2024-2025
|
||||
|
||||
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
|
||||
|
|
@ -19,6 +19,6 @@ along with Mtools. If not, see <http://www.gnu.org/licenses/>.
|
|||
from gettext import translation
|
||||
from pathlib import Path
|
||||
|
||||
t = translation("rougail_cli", str(Path(__file__).parent / "locale"))
|
||||
t = translation("rougail_cli", str(Path(__file__).parent / "locale"), fallback=True)
|
||||
|
||||
_ = t.gettext
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in a new issue