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

Allow custom cli options #355

Closed
andeersg opened this issue Dec 26, 2018 · 3 comments
Closed

Allow custom cli options #355

andeersg opened this issue Dec 26, 2018 · 3 comments

Comments

@andeersg
Copy link

I was trying to implement a feature for my site to optionally show drafts (like Jekyll has).

Basically I have a front matter flag on posts:

draft: true

And if I add --include-drafts or --drafts I could do a check in my eleventy.js to either include or filter out the posts with draft: true.

Example:

const includeDrafts = process.argv.filter(i => i == '--include-drafts').length > 0 ? true : false;

But this is currently not possible because of this check:
https://github.com/11ty/eleventy/blob/master/src/EleventyCommandCheck.js#L73

I think it would make Eleventy even more powerful if it just ignores options it does not recognise so it's possible to add custom functionality with custom options.

@andeersg
Copy link
Author

If I comment out throw new EleventyCommandCheckError this seems to work, but I don't know if this could cause other problems.

@zachleat
Copy link
Member

zachleat commented Jan 7, 2019

Ah, I don’t think this will probably make it in, unfortunately. This behavior has actually saved my butt a few times when I’ve mistyped a command and it failed immediately without writing files.

You can see the decision making behind the behavior here: #66 (Eleventy used to operate how you suggested, but was changed to this model for safety reasons)

I’d encourage you to use environment variables instead. We have an example of those in the docs: https://www.11ty.io/docs/data-js/#example%3A-exposing-environment-variables

Related discussion in the permalink: false issue that was implemented: #61 docs: https://www.11ty.io/docs/permalinks/#permalink%3A-false

And this feature is actually our top feature request to include in core, so it will very likely get included in core soon: #188

Sorry, hope that’s not too disappointing of an answer!

(Closing.)

@zachleat zachleat closed this as completed Jan 7, 2019
@andeersg
Copy link
Author

andeersg commented Jan 8, 2019

Not disappointing at all, I can live with environment variables :)

Really love Eleventy so far 👍

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