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

Only run command_main() when calling from command line #265

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jlbosse
Copy link

@jlbosse jlbosse commented Oct 30, 2023

Wrapped the call of command_main() in an if abspath(PROGRAM_FILE) == @__FILE__ to run it only if the sript is directly called from the command line. This makes it possible to include() Comonicon scripts as well and use the functions defined in them in other applications as well.

This addresses #260

Let me know if you also want me to add a sentence or two about this changed behaviour to the documentation

@Roger-luo
Copy link
Collaborator

I just realized #257 is related to this, the new behavior of Julia's entry point is basically what this PR implements, but I'm not sure what's the best way of supporting this now given this is a 1.10+ feature and we are supporting all 1.6+.

@jlbosse
Copy link
Author

jlbosse commented Oct 31, 2023

AFAICT the question of what happens with the @main macro (and if it simply gets renamed to e.g. @app) and if we automatically run command_main() when includeing a Comonicon based script are independent?

Or did you have plans to make bigger changes than renaming @main to fix #257 ?

@Roger-luo
Copy link
Collaborator

maybe let's double check with @Keno, IIUC after shipping @main from Base if main is defined then the behaviour in this PR is supported by Julia already?

@jlbosse
Copy link
Author

jlbosse commented Nov 3, 2023

Ah yes, it makes sense to see what Base.@main will do. I suppose there will be a suggested way to also support older julia versions, similar to the way there are these instructions to make weak dependencies work on older julia versions?

@Roger-luo
Copy link
Collaborator

Yeah so I think we will have to wait for something like that before merging this PR.

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

Successfully merging this pull request may close these issues.

2 participants