Skip to content

Commit 53a0606

Browse files
author
developerworks
committed
Refactor generate-template --output to use full path instead of file name only
- Change --output to accept full output path instead of extracting file name under config/<root_config_name>/ - Update CLI argument description and doc strings in src/cli.rs - Remove '#' comment prefix from YAML template section/field/leaf keys - Update unit tests for new output resolution and remove '#' prefix assertions - Add test for resolve_config_template_output with provided path - Sync all 11 locale manual/cli.md files and README.zh.md documentation
1 parent 632870b commit 53a0606

17 files changed

Lines changed: 69 additions & 67 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rust-config-tree"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
edition = "2024"
55
rust-version = "1.85"
66
description = "Recursive include tree utilities for layered configuration files."

README.zh.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -348,13 +348,13 @@ fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
348348
}
349349
```
350350

351-
`generate-template --output <file-name>`
352-
会在 `config/<root_config_name>/` 下写入模板,并使用指定的文件名。如果传入的是路径,只取它的文件名。未提供
353-
output file name(输出文件名) 时,写入
354-
`config/<root_config_name>/<root_config_name>.example.yaml`添加
355-
`--schema <path>` TOMLYAMLJSON 和 JSON5 模板会绑定生成的
356-
JSON Schema 集合。这也会把 root schema(根结构定义) 和
357-
section schema(配置段结构定义) 写入指定的 schema path(结构定义路径)
351+
`generate-template --output <path>`
352+
会把模板写入指定的 output path(输出路径). 未提供
353+
`--output` 时, 写入
354+
`config/<root_config_name>/<root_config_name>.example.yaml`. 添加
355+
`--schema <path>` , TOML, YAML, JSON 和 JSON5 模板会绑定生成的
356+
JSON Schema(JSON 结构定义) 集合. 这也会把 root schema(根结构定义) 和
357+
section schema(配置段结构定义) 写入指定的 schema path(结构定义路径).
358358

359359
`generate-schema --output <path>` 会写入 root(根配置) 的 Draft 7
360360
JSON Schema(JSON 结构定义) 和 section schema(配置段结构定义)。未提供

manual/de/cli.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,8 @@ fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
9292
demo generate-template
9393
```
9494

95-
Der Befehl schreibt Vorlagen unter `config/<root_config_name>/`. Wenn `--output`
96-
einen Pfad erhaelt, wird nur der Dateiname verwendet. Wenn kein
97-
Ausgabe-Dateiname angegeben wird, schreibt der Befehl
95+
Der Befehl schreibt Vorlagen in den von `--output` angegebenen Ausgabepfad.
96+
Wenn kein `--output` angegeben wird, schreibt der Befehl
9897
`config/<root_config_name>/<root_config_name>.example.yaml`. Fuege
9998
`--schema schemas/myapp.schema.json` hinzu, um erzeugte TOML-, YAML-, JSON- und
10099
JSON5-Vorlagen an erzeugte JSON-Schemas zu binden. Aufgeteilte YAML-Vorlagen

manual/en/cli.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,8 @@ fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
9696
demo generate-template
9797
```
9898

99-
The command writes templates under `config/<root_config_name>/`. If `--output`
100-
receives a path, only the file name is used. If no output file name is provided,
101-
the command writes
99+
The command writes templates to the output path specified by `--output`. If no
100+
`--output` is provided, the command writes
102101
`config/<root_config_name>/<root_config_name>.example.yaml`. Add
103102
`--schema schemas/myapp.schema.json` to bind generated TOML, YAML, JSON, and JSON5 templates
104103
to generated JSON Schemas. Split YAML templates bind the matching section

manual/es/cli.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,8 @@ fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
9494
demo generate-template
9595
```
9696

97-
El comando escribe plantillas bajo `config/<root_config_name>/`. Si `--output`
98-
recibe una ruta, solo se usa el nombre de archivo. Si no se proporciona un
99-
nombre de archivo de salida, el comando escribe
97+
El comando escribe plantillas en la ruta de salida indicada por `--output`. Si
98+
no se proporciona `--output`, el comando escribe
10099
`config/<root_config_name>/<root_config_name>.example.yaml`. Añade
101100
`--schema schemas/myapp.schema.json` para enlazar plantillas TOML, YAML, JSON y
102101
JSON5 generadas a JSON Schemas generados. Las plantillas YAML divididas enlazan

manual/fi/cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
8484
demo generate-template
8585
```
8686

87-
Komento kirjoittaa mallit hakemistoon `config/<root_config_name>/`. Jos `--output` saa polun, vain tiedostonimi kaytetaan. Jos tulostetiedoston nimea ei anneta, komento kirjoittaa `config/<root_config_name>/<root_config_name>.example.yaml`. Lisaa `--schema schemas/myapp.schema.json`, jotta luodut TOML-, YAML-, JSON- ja JSON5-mallit sidotaan luotuihin JSON Schema -skeemoihin. Jaetut YAML-mallit sitovat vastaavan osioskeeman. JSON- ja JSON5-mallit saavat `$schema`-kentan, jonka VS Code tunnistaa. Komento kirjoittaa myos juuri- ja osioskeemat valittuun skeemapolkuun.
87+
Komento kirjoittaa mallit `--output`-arvon osoittamaan tulostepolkuun. Jos `--output`-arvoa ei anneta, komento kirjoittaa `config/<root_config_name>/<root_config_name>.example.yaml`. Lisaa `--schema schemas/myapp.schema.json`, jotta luodut TOML-, YAML-, JSON- ja JSON5-mallit sidotaan luotuihin JSON Schema -skeemoihin. Jaetut YAML-mallit sitovat vastaavan osioskeeman. JSON- ja JSON5-mallit saavat `$schema`-kentan, jonka VS Code tunnistaa. Komento kirjoittaa myos juuri- ja osioskeemat valittuun skeemapolkuun.
8888

8989
```bash
9090
demo generate-template --output app_config.example.toml --schema schemas/myapp.schema.json

manual/fr/cli.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,8 @@ fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
9393
demo generate-template
9494
```
9595

96-
La commande ecrit les modeles sous `config/<root_config_name>/`. Si `--output`
97-
recoit un chemin, seul le nom de fichier est utilise. Si aucun nom de fichier de
98-
sortie n'est fourni, la commande ecrit
96+
La commande ecrit les modeles dans le chemin de sortie indique par `--output`.
97+
Si aucun `--output` n'est fourni, la commande ecrit
9998
`config/<root_config_name>/<root_config_name>.example.yaml`. Ajoutez
10099
`--schema schemas/myapp.schema.json` pour lier les modeles TOML, YAML, JSON et
101100
JSON5 generes aux schemas JSON generes. Les modeles YAML separes lient le

manual/ja/cli.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,8 @@ fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
9090
demo generate-template
9191
```
9292

93-
この command は `config/<root_config_name>/` の下に template を書きます。
94-
`--output` に path を渡した場合は file name だけを使います。output file name
95-
がない場合は
93+
この command は `--output` が指定した output path に template を書きます。
94+
`--output` がない場合は
9695
`config/<root_config_name>/<root_config_name>.example.yaml` を書きます。
9796
`--schema schemas/myapp.schema.json` を追加すると、generated TOML / YAML /
9897
JSON / JSON5 template を generated JSON Schema に bind します。split YAML

manual/ko/cli.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
8888
demo generate-template
8989
```
9090

91-
명령은 `config/<root_config_name>/` 아래에 템플릿을 씁니다. `--output`이 경로를
92-
받으면 파일 이름만 사용합니다. 출력 파일 이름을 제공하지 않으면
91+
명령은 `--output`이 지정한 출력 경로에 템플릿을 씁니다. `--output`을 제공하지 않으면
9392
`config/<root_config_name>/<root_config_name>.example.yaml`을 씁니다. 생성된
9493
TOML, YAML, JSON 및 JSON5 템플릿을 생성된 JSON Schema에 바인딩하려면
9594
`--schema schemas/myapp.schema.json`를 추가하세요. 분할 YAML 템플릿은 대응하는

manual/nl/cli.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,8 @@ fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
9191
demo generate-template
9292
```
9393

94-
De opdracht schrijft sjablonen onder `config/<root_config_name>/`. Als
95-
`--output` een pad ontvangt, wordt alleen de bestandsnaam gebruikt. Als geen
96-
uitvoerbestandsnaam is opgegeven, schrijft de opdracht
94+
De opdracht schrijft sjablonen naar het uitvoerpad dat door `--output` is
95+
opgegeven. Als geen `--output` is opgegeven, schrijft de opdracht
9796
`config/<root_config_name>/<root_config_name>.example.yaml`. Voeg
9897
`--schema schemas/myapp.schema.json` toe om gegenereerde TOML-, YAML-, JSON- en
9998
JSON5-sjablonen te koppelen aan gegenereerde JSON Schemas. Gesplitste

0 commit comments

Comments
 (0)