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

Include groovy-cli into dependencies #2857

Closed
ssadedin opened this issue May 10, 2022 · 4 comments
Closed

Include groovy-cli into dependencies #2857

ssadedin opened this issue May 10, 2022 · 4 comments

Comments

@ssadedin
Copy link

ssadedin commented May 10, 2022

New feature

Nextflow currently includes a number of useful Groovy core libraries that enable various native Groovy functions to be used in building pipeline scripts.

I would like to propose that one of the groovy-cli modules be added. I think perhaps the more light weight cli-commons module might be more appropriate as I'm sure there is a strong desire to keep the Nextflow download light weight.

Why I'm suggesting this

One of the nice features of Bpipe that I miss in Nextflow is built in options parsing. In Bpipe, you can very easily make the pipeline consume arguments such as flags, validate their types and provide comprehensive help output, because this is all built into Groovy.

Usage scenario

This feature would enable people to easily build in sophisticated argument parsing and help for their Nextflow pipelines.

Suggest implementation

You don't need to do anything, simply add one of the groovy-cli modules as a dependency. Then users can write things like

cli = new CliBuilder(usage:'My fancy pipeline').tap {
   my_option 'This option is very important', args: 1, required: true
}
options = cli.parse(args)

println "Running the pipeline with the option $options.my_option"

and they can run it with Nextflow like:

./nextflow my_pipeline.nf -my_option the_option_value

NB: I know users can accomplish this themselves with Groovy but I feel it's a really nice benefit in this case to have it built in.

@pditommaso
Copy link
Member

Not sure I'm missing something, but nextflow has built-in options parsing as well.

Just try

cat <<EOT >> hello.nf
params.foo = 'Hello world'
println params.foo
EOT

then run

nextflow run hello.nf --foo Hola

@stale stale bot added the stale label Oct 16, 2022
@nextflow-io nextflow-io deleted a comment from stale bot Oct 16, 2022
@pditommaso
Copy link
Member

Closing for lack of activity

@stale stale bot removed the stale label Oct 16, 2022
@cerebis
Copy link

cerebis commented Jun 22, 2024

An old issue, but every time sit down to nextflow -- and think about offering users a robust interface -- it perhaps evokes the same thought as motivated @ssadedin to post a feature request.

Sure, Nextflow has basic abilities to parse arguments but you cannot define a CLI and validate it. I've just been studying nf-core again, in hopes that they have solved this issue. Their CLIs are very nice by Nextflow standards, but seem to be hand-crafted in each case.

I would point to Python's argparse or the much older Apache Java commnons-cli as examples.

@bentsherman
Copy link
Member

We are discussing an overhaul of pipeline params, including the validation of CLI params against a schema: #4669

Feel free to share your thoughts there, I have also sketched out a few ideas

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

4 participants