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

Expand glob patterns if the shell does not support it #102

Open
dominic-simplan opened this issue Apr 14, 2020 · 5 comments
Open

Expand glob patterns if the shell does not support it #102

dominic-simplan opened this issue Apr 14, 2020 · 5 comments
Assignees

Comments

@dominic-simplan
Copy link

Hi,

is it possible to convert mulptile adoc files at once from the CLI using wildcards?
For example as described here: https://asciidoctor.org/docs/user-manual/#process-multiple-source-files-from-the-cli

However, this doesn't seem to work (at least on Windows) in asciidoctor.js:

PS> npx asciidoctor *.adoc  
ENOENT: no such file or directory, open '*.adoc'
PS> npx asciidoctor '*.adoc'
ENOENT: no such file or directory, open '*.adoc'
@ggrossetie
Copy link
Member

Hello @dominic-simplan

is it possible to convert mulptile adoc files at once from the CLI using wildcards?
For example as described here: https://asciidoctor.org/docs/user-manual/#process-multiple-source-files-from-the-cli

Yes it's possible but it's a shell feature. If supported, your shell will automatically expand the pattern. I'm not a Windows expert but apparently it does not work on Windows PowerShell 😞

@dominic-simplan
Copy link
Author

dominic-simplan commented Apr 14, 2020

Hi,
thanks for the quick reply!
It seems like the default asciidoctor cli has a cross-platform way to deal with this:

Since the globs in this command rely on shell expansion, the command is not portable across platforms. To make it portable, you can allow the Asciidoctor CLI to expand the globs. To do so, instruct the shell to not expand the glob by quoting the pattern, as shown here:

$ asciidoctor '.adoc' '/*.adoc'

So this is not supported in asciidoctor.js-cli I assume?

@ggrossetie
Copy link
Member

Indeed, I didn't know that the Asciidoctor (Ruby) CLI can expand globs.

So this is not supported in asciidoctor.js-cli I assume?

No, currently it's not supported but since it's supported by Asciidoctor (Ruby) CLI we should also support it.
Can I rename this issue to make it clear that this issue is now about "expanding globs when the shell does not support it"?

@dominic-simplan
Copy link
Author

Sure, and thanks for the help :-)

@ggrossetie ggrossetie self-assigned this Apr 14, 2020
@ggrossetie ggrossetie changed the title Convert multiple files from CLI using wildcards Expand glob patterns if the shell does not support it Apr 14, 2020
@ggrossetie
Copy link
Member

ggrossetie commented Apr 14, 2020

Here's the logic in Asciidoctor Ruby:

https://github.com/asciidoctor/asciidoctor/blob/a1fa9d555eaca835cdc1e30fb2ddc2c83523bd81/lib/asciidoctor/cli/options.rb#L209-L228

We should probably use the glob library even if there are some small differences with Ruby Dir.glob.

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

No branches or pull requests

2 participants