mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-19 06:20:38 -07:00
feat!: remove --template CLI option
Template is positional-only; bare stdin template and --template/-t are both removed. Keep @- for template and --context. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
+2
-13
@@ -14,8 +14,7 @@ async function render () {
|
||||
program
|
||||
.name('liquidjs')
|
||||
.description('Render a Liquid template')
|
||||
.argument('[template]', 'liquid template to render (inline, @path, or @- for stdin)')
|
||||
.option('-t, --template <liquid | @path>', 'liquid template to render (inline, @path, or @- for stdin)')
|
||||
.argument('<template>', 'liquid template to render (inline, @path, or @- for stdin)')
|
||||
.option('-c, --context <json | @path>', 'input context in JSON format (inline, @path, or @- for stdin)')
|
||||
.option('-o, --output <path>', 'write rendered output to file (omit to write to stdout)')
|
||||
.option('--cache [size]', 'cache previously parsed template structures (default cache size: 1024)')
|
||||
@@ -46,17 +45,7 @@ async function render () {
|
||||
.parse()
|
||||
|
||||
const options = program.opts()
|
||||
const positionalTemplate = program.args[0]
|
||||
const optionTemplate = options.template
|
||||
|
||||
if (positionalTemplate && optionTemplate && positionalTemplate !== optionTemplate) {
|
||||
throw new Error(`Conflicting templates: positional argument and --template differ.`)
|
||||
}
|
||||
|
||||
const templateOption = positionalTemplate || optionTemplate
|
||||
if (!templateOption) {
|
||||
throw new Error(`A template is required. Pass a positional <template> or --template.`)
|
||||
}
|
||||
const templateOption = program.args[0]
|
||||
|
||||
if (Object.values({ template: templateOption, context: options.context }).filter((value) => value === '@-').length > 1) {
|
||||
throw new Error(`The stdin input specifier '@-' must only be used once.`)
|
||||
|
||||
Reference in New Issue
Block a user