Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unpredictable output #490

Open
noraj opened this issue Dec 5, 2022 · 1 comment
Open

Unpredictable output #490

noraj opened this issue Dec 5, 2022 · 1 comment

Comments

@noraj
Copy link

noraj commented Dec 5, 2022

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 marp-team/marp#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

@noraj noraj added the bug Something isn't working label Dec 5, 2022
@yhatt yhatt removed the bug Something isn't working label Dec 5, 2022
@yhatt
Copy link
Member

yhatt commented Dec 5, 2022

--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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants