Fuzzy finder

12 views
Skip to first unread message

theonlygusti

unread,
Jan 19, 2017, 3:31:50 AM1/19/17
to jcommander
Is it possible to make all option names use a fuzzy finder?

E.g. I define

@Parameter(names = "rename", arity = 2)
private List<String> rename;

And then I'd be able to call the program <main> with all of these command line options

<main> rename potato tomato
<main> ren potato tomato
<main> rme potato tomato

to accomplish the same things.

How would I be able to implement this using JCommander? Is it indeed possible?

Cédric Beust ♔

unread,
Jan 19, 2017, 12:19:40 PM1/19/17
to jcommander
Not possible at the moment but it should be pretty easy to add a special fuzzy mode to JCommander. The main difference would be that instead of getting the key from a map, you'd extract all the existing keys and do a substring match on them (assuming that's what you mean by fuzzy).

Not convinced it's really that useful but it can be done in a backward compatible way (you'd have to configure your JCommander object to work in fuzzy mode before parsing), so I'm not opposed to it.


-- 
Cédric


--
You received this message because you are subscribed to the Google Groups "jcommander" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jcommander+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

gbakewell7

unread,
Jan 19, 2017, 12:21:54 PM1/19/17
to jcommander
Using the current JCommander, is there an efficient way for me to
implement this in my own project? Or would I have to convert all the
options myself before passing them to JCommander? (Which honestly
almost defeats its purpose :P)

Cédric Beust ♔

unread,
Jan 19, 2017, 12:44:16 PM1/19/17
to jcommander
JCommander doesn't have support for plug-ins, so no, short of sending a pull request to modify it, there is no way to add this functionality to it right now.

I've wondered a few times about adding plug-ins to JCommander but this has always struck me as overkill for a simple command line parsing library.


-- 
Cédric


gbakewell7

unread,
Jan 19, 2017, 12:49:43 PM1/19/17
to jcommander
Are plugins really ever overkill though? I think everyone respects
bare-bones but extendable libraries.

I'll look into the code though, it's really something I'd like to be
able to use.
Reply all
Reply to author
Forward
0 new messages