Giter Site home page Giter Site logo

Comments (22)

danielsoro avatar danielsoro commented on September 18, 2024

Maybe a shortcut?

@Option("foo", shortcut="f"); 

from crest.

rmannibucau avatar rmannibucau commented on September 18, 2024

actually I guess the need is aliases: https://github.com/kohsuke/args4j/blob/master/args4j/src/org/kohsuke/args4j/Option.java

from crest.

danielsoro avatar danielsoro commented on September 18, 2024

@rmannibucau +1

from crest.

dblevins avatar dblevins commented on September 18, 2024

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.

rmannibucau avatar rmannibucau commented on September 18, 2024

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.

dblevins avatar dblevins commented on September 18, 2024

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.

danielsoro avatar danielsoro commented on September 18, 2024

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.

rmannibucau avatar rmannibucau commented on September 18, 2024

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.

dblevins avatar dblevins commented on September 18, 2024

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.

rmannibucau avatar rmannibucau commented on September 18, 2024

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.

dblevins avatar dblevins commented on September 18, 2024

+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.

tomitribe-dev avatar tomitribe-dev commented on September 18, 2024

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.

rmannibucau avatar rmannibucau commented on September 18, 2024

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.

danielsoro avatar danielsoro commented on September 18, 2024

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.

tomitribe-dev avatar tomitribe-dev commented on September 18, 2024

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.

rmannibucau avatar rmannibucau commented on September 18, 2024

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.

jgallimore avatar jgallimore commented on September 18, 2024

I'm happy to have a go at this issue this week - but please shout if someone else wants to take it.

from crest.

danielsoro avatar danielsoro commented on September 18, 2024

@jgallimore I would like to do it! :'(

from crest.

jgallimore avatar jgallimore commented on September 18, 2024

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.

danielsoro avatar danielsoro commented on September 18, 2024

Thanks @jgallimore

from crest.

danielsoro avatar danielsoro commented on September 18, 2024

Feedback:
Build - OK
Tests - Fail
I changed somethings on tomitribe-util. [PR sent]

from crest.

danielsoro avatar danielsoro commented on September 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.