Unpredictable output
Version of Marp Tool
v1.7.2
Operating System
Windows
Environment
- OS version: ArchLinux and Alpine 3.16
- Node.js version: marp core v2.4.2, nodejs v16.18.0
How to reproduce
By default, I expect the output file to go into the current/working directory and not in the input directory (at the same level as the input file). I understand that this is debatable and suggestive.
$ marp --theme-set themes --input-dir docs
[ INFO ] Converting 1 markdown...
[ INFO ] docs/slides.md => docs/slides.html
So if I want to be sure to control the output path I'll use the --output option which has this exact purpose.
$ marp --theme-set themes --output index.html --input-dir docs
[ INFO ] Converting 1 markdown...
[ INFO ] docs/slides.md => index.html/slides.html
The --output should be relative to the current/working directory so I expect the file index.html to go to $PWD/index.html. At list an expected bad behavior would be it still output to $PWD/docs/index.html. But here what the help message says:
$ -o, --output Output file path (or directory when
input-dir is passed) [string]
So when input-dir is provided, --output is interpreted as a directory and not a file anymore, so it outputs to index.html/slides.html. Meaning I can control the output dir but not longer the file name.
$ marp --theme-set themes --output test --input-dir docs
[ INFO ] Converting 1 markdown...
[ INFO ] docs/slides.md => test/slides.html
$ marp --theme-set themes --output test/index.html --input-dir docs
[ INFO ] Converting 1 markdown...
[ INFO ] docs/slides.md => test/index.html/slides.html
Same context as in https://github.com/marp-team/marp/discussions/382
Expected behavior
eg curl has 2 options:
$ curl --help all | grep '\--output'
-o, --output <file> Write to file instead of stdout
--output-dir <dir> Directory to save files in
There should definitely be an --output-file and an --output-dir option with predictable behavior and not one --output option with unpredictable behavior that change relatively to other option being used.
Actual behavior
See How to reproduce
Additional information
No response
--input-dir (-I) option has designed mutually exclusive to regular inputs, as indicated in the usage section of marp --help. (Perhaps CLI help may be insufficient informing users about input exclusivity)
$ marp --help
Usage:
marp [options] <files...>
marp [options] -I <dir>
Details...
Regular inputs and --input-dir option cannot mix, but we allow glob pattern and directories as inputs. If specified directories, Marp CLI will convert every Markdown files inside directories.
--input-dir option is mainly used for server mode (-s) to determine a "unique" root directory. In non-server mode, --input-dir means processing "directory to directory" conversion.
From the standpoint of this exclusivity, we had thought that splitting --output option into two options would be redundant.
If decided to introduce --output-dir, it is up for discussion whether it should be just an alias for the --output option corresponding to --input-dir, or whether it should be an available option also in regular input files.