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

Add ability to pick which script is installed if repo provides multiple #18

Open
justone opened this issue Sep 3, 2022 · 3 comments
Open

Comments

@justone
Copy link

justone commented Sep 3, 2022

Awesome project, thanks for creating it! I tried it out and everything is working so far.

I have a repo containing multiple babashka scripts, each with its own main.

For now, I need to specify the main opts and the script name on the bbin install line, like this:

bbin install --as empath io.github.justone/bb-scripts --main-opts '["-m" "empath"]'

Since the :bbin/bin value in the repo's bb.edn file is a map, how about supporting a way of picking which script is installed? Something like this:

bbin install io.github.justone/bb-scripts --select empath

It could even be extended to support an :all keyword to install all scripts found.

Thanks again.

@rads
Copy link
Collaborator

rads commented Sep 6, 2022

Thanks for creating this issue. It's definitely something I've had in mind while building the initial version, even though I had to leave it out.

Right now we assume there is only one entry in :bbin/bin, so we need to think how we can support multiple entries while still prioritizing the more common case of having one script per lib.

What should happen if a lib has multiple scripts in :bbin/bin and --select is not provided? Do we error out?

What about providing a default script to install when there are multiple? Should this be supported? Perhaps a lib author could add a key in the script config such as :bbin/default true?

@justone
Copy link
Author

justone commented Sep 6, 2022

Yeah, I think having a :bbin/default key to true is a good idea. As I was reading your comment, that's what came to mind. I think it might be good in that case to print a message like this:

io.github.justone/bb-scripts provides multiple scripts. Installing "foobar" by default.

That also makes me think that there could be a way of discovering what scripts are available. Perhaps:

bbin install io.github.justone/bb-scripts --list

That way the above "default" message can include a hint about running with --list as can the error message when no script is selected and there isn't a default.

$ bbin install io.github.justone/bb-scripts
io.github.justone/bb-scripts provides multiple scripts. Installing "foobar" by default.
...
Run "bbin install io.github.justone/bb-scripts --list" to see all available scripts.
$ bbin install io.github.justone/bb-scripts --list
empath
penv
comb
$ bbin install io.github.justone/bb-scripts --select penv

Now that I reflect back on writing all of that, I think that perhaps the --list (and :bbin/default key even) might be a bit much. Users presumably started at a script repository's readme and would know what is available. With this in mind, maybe the simplest thing is just to error when a script is not selected (and there are multiple) and leave it at that.

@logseq-cldwalker
Copy link

I have a repo containing multiple babashka scripts, each with its own main.

I also have the same setup at https://github.com/logseq/bb-tasks though I'm wanting to install all my scripts at once. Since :bbin/bin is a map, I thought I could do something in bb.edn like:

:bbin/bin
{logseq-import {:main-opts ["-m" "logseq.bb-tasks.bin.logseq-import/-main"]
 logseq-export {:main-opts ["-m" "logseq.bb-tasks.bin.logseq-export/-main"]}

When it only picked the first one I thought it was a bug until I found this issue. If this is unrelated enough, I could open a separate issue. Thanks for the great tool!

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