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

Optional modules #1796

Closed
casey opened this issue Dec 29, 2023 · 4 comments
Closed

Optional modules #1796

casey opened this issue Dec 29, 2023 · 4 comments

Comments

@casey
Copy link
Owner

casey commented Dec 29, 2023

From a comment by @laniakea64:

But in testing out replacing this recipe with mod foo 'some_repo/foo/justfile', came across a couple points that block this usage:

The main place I have such recipe is in a justfile that manages temporary clones of a couple repos. So the repo that contains the justfile I would use as module does not always exist. Currently this state causes error: Failed to read justfile that prevents running any recipes. Could there please be a way for "module only if specified file exists", i.e. if the module file is not found at the specified path, the justfile doesn't error out but the module/subcommands simply doesn't work?

How about the following syntax?

# without a path:
mod foo?

# with a path:
mod foo? 'bar.just'

A module with a ? wouldn't provoke a warning or error when not found.

It could also be:

# without a path:
mod? foo
mod? foo 'bar.just'

mod foo?
mod foo 'bar.just'?

Which could be used with import statements, which lack a module name:

import? 'foo.just'
import 'foo.just'?
@crdx
Copy link
Contributor

crdx commented Dec 29, 2023

I was about to raise an issue suggesting the exact same thing re import.

I have some public repositories where I would like some non-public recipes in a gitignored justfile. I can only use import for this if it's possible to optionally import.

The syntax that feels most natural to me is import? 'foo.just'. The ? at the end of the line reminds me of rust where it has a different meaning.

@laniakea64
Copy link
Contributor

The syntax that feels most natural to me is import? 'foo.just'.

+1 for the mod? foo 'bar.just' / import? 'foo.just' form

@casey
Copy link
Owner Author

casey commented Dec 29, 2023

Done in #1797!

With the mod? and import? syntax:

mod? foo
import? "foo.just"

@crdx
Copy link
Contributor

crdx commented Dec 29, 2023

Love how quickly you get stuff done.

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

3 participants