-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Fluid template engine, -e to specify engine and -x for managing…
… template files' extension associations (#29)
- Loading branch information
Showing
18 changed files
with
477 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
--- | ||
title: CLI options | ||
tags: [quick-start, cli-usage] | ||
--- | ||
## General format for options | ||
|
||
### Shortcut Option (Single Character) | ||
|
||
Shortcut options are prefixed with a single hyphen (-) and can be followed directly by the value without a space, though a space can be used if preferred. | ||
**Example:** | ||
|
||
- Without space: `-tpath/to/template` | ||
- With space: `-t path/to/template` | ||
|
||
### Long Version Option (Double Dash) | ||
|
||
Long options are prefixed with double hyphens (--), the first letter of the option is uppercase, and the option name is followed by an equal sign (=) to assign its value. | ||
**Example:** `--Template=path/to/template` | ||
|
||
## Option Values | ||
|
||
### Single Value | ||
|
||
An option can take a single value, which is provided right after the shortcut or the `=` sign for long options. | ||
**Example**: `-s path/to/source` or `--Source=path/to/source` | ||
|
||
### Switch Values | ||
|
||
If an option accepts a boolean, this one can be omitted. | ||
**Example**: `-i` or `--StdIn` or `--StdIn=true` | ||
|
||
### Multiple Values | ||
|
||
If an option accepts multiple values, the values should be separated by a semicolon (;). | ||
**Example**: `--Sources=file1.yaml;file2.json;file3.xml` | ||
|
||
### Key-Value Pairs | ||
|
||
For key-value pairs, the key is followed by a colon (:), and then the value. Multiple key-value pairs, if allowed, should be separated by a semicolon (;). | ||
**Example**: `--Extensions=txt:handlebars;liquid:fluid` | ||
|
||
## Didot Options Explained | ||
|
||
### Template Option | ||
|
||
Shortcut: `-t` | ||
Long: `--Template` | ||
Description: Specifies the path to the template file. | ||
Accept: single value. | ||
Mandatory: yes. | ||
Example: `-tpath/to/template` or `--Template=path/to/template` | ||
|
||
### Engine option | ||
|
||
Shortcut: -e | ||
Long: --Engine | ||
Description: Specifies the template engine to use (scriban, fluid, dotliquid, handlebars, smartformat, stringtemplate). | ||
Accept: single value. When omitted Didot will select the engine based on the extension of the template file. | ||
Example: `-efluid` or `--Engine=fluid` | ||
|
||
### Source Option | ||
|
||
Shortcut: `-s` | ||
Long: `--Source` | ||
Description: Specifies the path to the source file. If omitted, input can be taken from StdIn. | ||
Accept: single value. | ||
Exclusive: can't be set with the parameter `--StdIn` | ||
Example: `-spath/to/source` or `--Source=path/to/source` | ||
|
||
### Parser Option | ||
|
||
Shortcut: -p | ||
Long: --Parser | ||
Description: Specifies the parser to use (YAML, JSON, XML). | ||
Accept: single value. | ||
Mandatory: no expect if `--StdIn` is specified. When omitted Didot will select the parser based on the extension of the source file | ||
Example: `-pYAML` or `--Parser=YAML` | ||
|
||
### StdIn Option | ||
|
||
Shortcut: `-i` | ||
Long: --StdIn | ||
Description: Specifies the input to the source data as coming from the StdIn. | ||
Accept: switch value. | ||
Exclusive: can't be set with the parameter `--Source` | ||
Example: `-i` or `--StdIn` | ||
|
||
### Output Option | ||
|
||
Shortcut: `-o` | ||
Long: `--Output` | ||
Description: Specifies the path to the generated output file. If omitted, output is rendered to StdOut. | ||
Accept: single value. | ||
Mandatory: no. | ||
Example: `-opath/to/output` or `--Output=path/to/output` | ||
|
||
### Extension option | ||
|
||
Shortcut: -x | ||
Long: --Extension | ||
Description: Specifies additional or replacing link between extensions and engine for automatic detection | ||
Accept: multiple key-value pairs. | ||
Mandatory: no. | ||
Example: `-xtxt:handlebars;liquid:fluid` or `--Extension=txt:handlebars;liquid:fluid` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
title: Specify template engine or parser | ||
tags: [cli-usage] | ||
--- | ||
## Specify the data parser | ||
|
||
- `-p, --Parser`: Defines the parser to use when the source data is provided through the console. Accepted values are `yaml`, `json` or `xml`. This option is required only when the `--Source` argument is omitted or if the extension of the source file is not recognized to determine the parser. | ||
|
||
```powershell | ||
didot -t template.hbs -s data.txt -p json -o output.txt | ||
``` | ||
|
||
In this example: | ||
|
||
- `template.hbs` is the Handlebars template file. | ||
- `data.txt` is the source file. | ||
- `json` is the parser of input data from the source file. | ||
- `output.txt` is the file where the output will be rendered. | ||
|
||
## Specify the template engine | ||
|
||
### Direct specification | ||
|
||
- `-e, --Engine`: Defines the template engine to use independantly of the template file extension. Accepted values are `scriban`, `dotliquid`, `fluid`, `handlebars`, `stringtemplate`, `smartformat`. | ||
|
||
```powershell | ||
didot -t template.txt -s data.json -e handlebars -o output.txt | ||
``` | ||
|
||
In this example: | ||
|
||
- `template.txt` is the template file. | ||
- `data.json` is the data JSON file. | ||
- `handlebars` is the template engine to use. | ||
- `output.txt` is the file where the output will be rendered. | ||
|
||
### Add or replace extension associations | ||
|
||
- `-x, --Extensions`: Defines the association of a file's extension with a template engine. More than one can be specified. | ||
|
||
```powershell | ||
didot -t template.txt -s data.json -x txt:handlebars;liquid:fluid -o output.txt | ||
``` | ||
|
||
In this example: | ||
|
||
- `template.txt` is the template file. | ||
- `data.json` is the data JSON file. | ||
- `txt:handlebars;liquid:fluid` is associating Handlbars to the extension `.txt` and Fluid to the extension `.liquid`. | ||
- `output.txt` is the file where the output will be rendered. | ||
|
||
By default following file's extension association are registered: | ||
|
||
- `.scriban` to Scriban | ||
- `.liquid` to DotLiquid | ||
- `.hbs` to Handlebars | ||
- `.smart` to SmartFormat | ||
- `.st` and `.stg` to StringTemplate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.