Comments (22)
Maybe a shortcut?
@Option("foo", shortcut="f");
from crest.
actually I guess the need is aliases: https://github.com/kohsuke/args4j/blob/master/args4j/src/org/kohsuke/args4j/Option.java
from crest.
@rmannibucau +1
from crest.
Aliases are fine. Brian can chime in if that's what he wanted.
We'd need short options regardless. Those should follow unix convention:
- Single dash and single character
- Can be strung together
E.g. these two would be the same
$ tar -c -z -v -f foo.tar.gz *.log
$ tar -czvf foo.tar.gz *.log
Definitely nice functionality to have.
David Blevins
http://twitter.com/dblevins
http://www.tomitribe.com
On Aug 5, 2014, at 4:59 AM, Romain Manni-Bucau [email protected] wrote:
actually I guess the need is aliases: https://github.com/kohsuke/args4j/blob/master/args4j/src/org/kohsuke/args4j/Option.java
—
Reply to this email directly or view it on GitHub.
from crest.
Well aliases are designed for it:
-A, --catenate, --concatenate
append tar files to an archive
-c, --create
create a new archive
-d, --diff, --compare
find differences between archive and file system
--delete
delete from the archive (not on mag tapes!)
-r, --append
append files to the end of an archive
-t, --list
list the contents of an archive
--test-label
test the archive volume label and exit
-u, --update
only append files newer than copy in archive
-x, --extract, --get
extract files from an archive
from crest.
Looks great. Just as long as we also get the short option there too and we don't use "--" on them.
On Aug 5, 2014, at 7:10 AM, Romain Manni-Bucau [email protected] wrote:
Well aliases are designed for it:
-A, --catenate, --concatenate
append tar files to an archive-c, --create
create a new archive-d, --diff, --compare
find differences between archive and file system--delete
delete from the archive (not on mag tapes!)-r, --append
append files to the end of an archive-t, --list
list the contents of an archive--test-label
test the archive volume label and exit-u, --update
only append files newer than copy in archive-x, --extract, --get
extract files from an archive—
Reply to this email directly or view it on GitHub.
from crest.
I think that we need to have shortcuts and alias.
Alias I can to define in runtime (.crestrc) or I can to call a command on crast that I can add a alist to command. IMHO.
shortchut is a small form to call it.
IMHO:
Command: DanielCommand
value = "daniel"
Options:
-A == shorcut | --address == option
Alias:
dc
Call forms:
daniel -A ..
daniel --address ...
dc -A ...
dc --address ...
Add alias:
crest.addAliast(Command, Alias);
or
read .crastrc (resources / home dir / somewhere )
Do you want add alias for Options too?
from crest.
In case of args4j aliases in @option are just a way to specify the same "java" parameter from another command line parameter. Works for shortcuts or even custom naming.
from crest.
Great. So for example:
@command
public void hello(@option("name", alias="n") String string)
These would be valid:
hello -n "Daniel"
hello --name "Daniel"
This would be invalid:
hello --n "Daniel"
On Aug 5, 2014, at 8:12 AM, Romain Manni-Bucau [email protected] wrote:
In case of args4j aliases in @option are just a way to specify the same "java" parameter from another command line parameter. Works for shortcuts or even custom naming.
—
Reply to this email directly or view it on GitHub.
from crest.
Hmm
Why not
@Command
public void hello(@Option("name", aliases={"-n", "-N", "--Name"}) String name)
?
Then question is shouldn't we just use value for it (String[]):
@Command
void hello(@Option({"--name", "-n", "-N", "--Name"}) String name);
// or
@Command
void hello(@Option("--name") String name)
And finally to make it complete I'd add a member nameResolver() of type NameResolver:
public interface NameResolver {
String resolve(String name);
}
Default would be the identity but it would allow to propose to resolve "name" to "--name" or "-name" or whatever depending the user need:
@Command
void hello(@Option("name", resolver = MyResolver.class) String name)
Can maybe allow:
hello name-> foo
Also suggest the type of param it should be (using = or not):
hello --name=foo
or
hello --name foo
from crest.
+1 for this:
@option({"name", "n", "N", "Name"})
On allowing any prefix or separator , I'd like to keep crest as simple as possible. Not a fan of supporting features only 1% of people will use and just add complexity the rest of the 99% have to deal with. So my vote would be against allowing "--" in the name and allowing resolvers or things like "->".
If people really really really want something like that, they can fork :)
On Aug 5, 2014, at 12:50 PM, Romain Manni-Bucau [email protected] wrote:
(@option({"--name", "-n", "-N", "--Name"}
from crest.
To be clear, still open to exploring additional syntax on Options, but let's move that to another topic.
Daniel, if you want to go ahead with "@option({"name", "n", "N", "Name"})" -- have at it! :)
On Aug 5, 2014, at 12:59 PM, David Blevins [email protected] wrote:
+1 for this:
@option({"name", "n", "N", "Name"})
On allowing any prefix or separator , I'd like to keep crest as simple as possible. Not a fan of supporting features only 1% of people will use and just add complexity the rest of the 99% have to deal with. So my vote would be against allowing "--" in the name and allowing resolvers or things like "->".
If people really really really want something like that, they can fork :)
On Aug 5, 2014, at 12:50 PM, Romain Manni-Bucau [email protected] wrote:
(@option({"--name", "-n", "-N", "--Name"}
—
Reply to this email directly or view it on GitHub.
from crest.
Hmm, issue with
@Option({"name", "n", "N", "Name"})
Is we don't know if we need -- or - or something else (no prefixes in most cases I saw).
What about:
@Option({"--name", "-n", "-N", "--Name"})
?
from crest.
Char with -
String with --
WDYT?
Daniel Cunha (soro) http://www.cejug.net
Blog: http://www.danielsoro.com.br
Twitter: https://twitter.com/dvlc_
GitHub: https://github.com/danielsoro
LinkedIn: http://www.linkedin.com/in/danielvlcunha
Sent from my cell phone
Em 05/08/2014 17:09, "Romain Manni-Bucau" [email protected]
escreveu:
Hmm, issue with
@option({"name", "n", "N", "Name"})
Is we don't know if we need -- or - or something else (no prefixes in most
cases I saw).What about:
@option({"--name", "-n", "-N", "--Name"})
?
—
Reply to this email directly or view it on GitHub
#3 (comment).
from crest.
Perfect.
On Tuesday, August 5, 2014, Daniel Cunha (soro) [email protected]
wrote:
Char with -
String with --WDYT?
Daniel Cunha (soro) http://www.cejug.net
Blog: http://www.danielsoro.com.br
Twitter: https://twitter.com/dvlc_
GitHub: https://github.com/danielsoro
LinkedIn: http://www.linkedin.com/in/danielvlcunha
Sent from my cell phone
Em 05/08/2014 17:09, "Romain Manni-Bucau" <[email protected]
javascript:_e(%7B%7D,'cvml','[email protected]');>
escreveu:Hmm, issue with
@option({"name", "n", "N", "Name"})
Is we don't know if we need -- or - or something else (no prefixes in
most
cases I saw).What about:
@option({"--name", "-n", "-N", "--Name"})
?
—
Reply to this email directly or view it on GitHub
#3 (comment).—
Reply to this email directly or view it on GitHub
#3 (comment).
from crest.
Sounds fair. Just a particular case: strings which are numbers (hello -10 instead of hello --10 to be consistent if using -1 -2 -3...)
from crest.
I'm happy to have a go at this issue this week - but please shout if someone else wants to take it.
from crest.
@jgallimore I would like to do it! :'(
from crest.
Go for it - it's yours! I just wanted to make sure we didn't end up duplicating effort. Please do shout if you need any help / info and send us a pull request and we'll get your changes merged in. Cheers!
from crest.
Thanks @jgallimore
from crest.
Feedback:
Build - OK
Tests - Fail
I changed somethings on tomitribe-util. [PR sent]
from crest.
Hello folks,
I finish the first step:
@option now support many values. :)
Tests run: 180, Failures: 0, Errors: 0, Skipped: 1
I'll work now to support char and set: -- with String and - with char. :)
from crest.
Related Issues (20)
- Support nested tables
- CDI integration
- support parameter interceptors
- when using aliases required parameters are broken
- support parameter injection HOT 4
- support inline documentation
- @Err and @Out seem to mess up args list
- org.tomitribe.crest.environments.Environment#ENVIRONMENT_THREAD_LOCAL shouldnt have a default
- Add a Mojo (mvn plugin) to generate all UNIx command scripts from found commands
- Null returned when using @Option and Bean Validation HOT 1
- Injected streams do not play work together with argument arrays
- PrintingOutput as alternative to StreamingOutput HOT 1
- Support 'Stream<String>' return types for commands
- Parameter values are converted to lowercase when passed on the command line HOT 6
- crest-maven-plugin: add java 11 support, upgrade ASM to >6 HOT 7
- Make the integration with GraalVM smoother HOT 1
- move helpprocessor in crest-processor
- Eliminate IllegalArgumentException "No interceptor for " issue with @CrestInterceptor HOT 2
- Support for descending sorts via "thefield>"
- Excluding fields from @Table output
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crest.