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

How we suggest command lining #21

Open
wants to merge 1 commit into
base: public
Choose a base branch
from
Open

Conversation

ctb
Copy link
Owner

@ctb ctb commented May 27, 2018

See rendered version

Comments welcome

@ctb ctb changed the base branch from master to public May 27, 2018 13:42
@ctb
Copy link
Owner Author

ctb commented May 28, 2018

https://github.com/bgruening/coding_for_big_data

@ctb
Copy link
Owner Author

ctb commented May 28, 2018

http://julio.meroh.net/2013/09/cli-design-handling-output-messages.html

@ctb
Copy link
Owner Author

ctb commented May 28, 2018

@ctb
Copy link
Owner Author

ctb commented May 28, 2018

@sjackman
Copy link

sjackman commented May 28, 2018

Handle multiple sets of multiple input files in a tab-completion friendly manner.

sourmash lca gather --query query1.sig query2.sig --db db1.sig db2.sig

It's unfortunately not easy to parse this command line using standard option parsing libraries, or perhaps not even possible with some libraries. Named arguments like --query and --db can take either 0 or 1 argument, but I'm most don't allow for 2+ arguments. The first step of some option parsing libraries is to move all the named options to the front of the command line, so the above becomes the following before the results are seen by caller of the library function.

sourmash lca gather --query --db -- query1.sig query2.sig db1.sig db2.sig

where -- indicates the separation between the named arguments and the positional arguments.

One notable example is C's getopt and getopt_long.
See https://www.gnu.org/software/libc/manual/html_node/Using-Getopt.html

The default is to permute the contents of argv while scanning it so that eventually all the non-options are at the end. This allows options to be given in any order, even with programs that were not written to expect this.

One possible solution is to repeat the named option.

sourmash lca gather --query=query1.sig --query=query2.sig --db=db1.sig --db=db2.sig
sourmash lca gather -q query1.sig -q query2.sig -d db1.sig -d db2.sig

A possible refinement is to make the most common option positional arguments and the other named arguments.

sourmash lca gather --db=db1.sig --db=db2.sig query1.sig query2.sig query3.sig query4.sig

@ctb
Copy link
Owner Author

ctb commented May 30, 2018

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