This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Scala CLI Library?

5 replies
joeygibson
Joined: 2009-08-07,
User offline. Last seen 3 years 12 weeks ago.
I may have just overlooked this, but I can't seem to find an answer online. Is there a Scala library for processing command-line arguments, similar to Getopts? I know that I can handle the command-line args manually through the args parameter to main(), but is there something better? Googling for "scala command line arguments" and similar phrases yield many pages about getting the command-line args, or about the arguments for Scala itself, but not doing things like --foo, -f, etc. 
I could use Commons CLI, but I wanted to see if there was something built-in, or preferred, first.
Joey

--
Blog: http://joeygibson.com
Twitter: http://twitter.com/joeygibson
FriendFeed: http://friendfeed.com/joeygibson
Facebook: http://facebook.com/joeygibson
extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.
Re: Scala CLI Library?

On Tue, Jan 19, 2010 at 09:46:04AM -0500, Joey Gibson wrote:
> I may have just overlooked this, but I can't seem to find an answer
> online. Is there a Scala library for processing command-line
> arguments, similar to Getopts? I know that I can handle the
> command-line args manually through the args parameter to main(), but
> is there something better? Googling for "scala command line arguments"
> and similar phrases yield many pages about getting the command-line
> args, or about the arguments for Scala itself, but not doing things
> like --foo, -f, etc.

It doesn't do nearly everything one might want, but it does do some
things you might want and some other things you might not know you want.

http://github.com/paulp/optional

Joshua.Suereth
Joined: 2008-09-02,
User offline. Last seen 32 weeks 6 days ago.
Re: Scala CLI Library?
Optional is one of those libraries that's just a good idea.

On Tue, Jan 19, 2010 at 9:57 AM, Paul Phillips <paulp [at] improving [dot] org> wrote:
On Tue, Jan 19, 2010 at 09:46:04AM -0500, Joey Gibson wrote:
> I may have just overlooked this, but I can't seem to find an answer
> online. Is there a Scala library for processing command-line
> arguments, similar to Getopts? I know that I can handle the
> command-line args manually through the args parameter to main(), but
> is there something better? Googling for "scala command line arguments"
> and similar phrases yield many pages about getting the command-line
> args, or about the arguments for Scala itself, but not doing things
> like --foo, -f, etc.

It doesn't do nearly everything one might want, but it does do some
things you might want and some other things you might not know you want.

 http://github.com/paulp/optional

--
Paul Phillips      | A Sunday school is a prison in which children do
Vivid              | penance for the evil conscience of their parents.
Empiricist         |     -- H. L. Mencken
pull his pi pal!   |----------* http://www.improving.org/paulp/ *----------

Grand, Mark D.
Joined: 2009-12-24,
User offline. Last seen 42 years 45 weeks ago.
RE: Scala CLI Library?

Perhaps it would be a good idea for someone to put it in the bazaar.

 

From: Josh Suereth [mailto:joshua [dot] suereth [at] gmail [dot] com]
Sent: Tuesday, January 19, 2010 4:05 PM
To: Paul Phillips
Cc: Joey Gibson; scala [at] listes [dot] epfl [dot] ch
Subject: Re: [scala] Scala CLI Library?

 

Optional is one of those libraries that's just a good idea.

On Tue, Jan 19, 2010 at 9:57 AM, Paul Phillips <paulp [at] improving [dot] org> wrote:

On Tue, Jan 19, 2010 at 09:46:04AM -0500, Joey Gibson wrote:
> I may have just overlooked this, but I can't seem to find an answer
> online. Is there a Scala library for processing command-line
> arguments, similar to Getopts? I know that I can handle the
> command-line args manually through the args parameter to main(), but
> is there something better? Googling for "scala command line arguments"
> and similar phrases yield many pages about getting the command-line
> args, or about the arguments for Scala itself, but not doing things
> like --foo, -f, etc.

It doesn't do nearly everything one might want, but it does do some
things you might want and some other things you might not know you want.

 http://github.com/paulp/optional

--
Paul Phillips      | A Sunday school is a prison in which children do
Vivid              | penance for the evil conscience of their parents.
Empiricist         |     -- H. L. Mencken
pull his pi pal!   |----------* http://www.improving.org/paulp/ *----------

 


This e-mail message (including any attachments) is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information. If the reader of this message is not the intended
recipient, you are hereby notified that any dissemination, distribution
or copying of this message (including any attachments) is strictly
prohibited.

If you have received this message in error, please contact
the sender by reply e-mail message and destroy all copies of the
original message (including attachments).
James.Strachan
Joined: 2009-07-08,
User offline. Last seen 2 years 25 weeks ago.
Re: Scala CLI Library?

FWIW last time I needed some option processing I grabbed Aaron
Harnly's code & hacked it a little so arguments and options print
themselves out nicely & added a mavenn/sbt build & tests

If anyone wants to keep hacking the code is here...
http://github.com/jstrachan/scopt

2010/1/19 Grand, Mark :
> Perhaps it would be a good idea for someone to put it in the bazaar.
>
>
>
> From: Josh Suereth [mailto:joshua [dot] suereth [at] gmail [dot] com]
> Sent: Tuesday, January 19, 2010 4:05 PM
> To: Paul Phillips
> Cc: Joey Gibson; scala [at] listes [dot] epfl [dot] ch
> Subject: Re: [scala] Scala CLI Library?
>
>
>
> Optional is one of those libraries that's just a good idea.
>
> On Tue, Jan 19, 2010 at 9:57 AM, Paul Phillips wrote:
>
> On Tue, Jan 19, 2010 at 09:46:04AM -0500, Joey Gibson wrote:
>> I may have just overlooked this, but I can't seem to find an answer
>> online. Is there a Scala library for processing command-line
>> arguments, similar to Getopts? I know that I can handle the
>> command-line args manually through the args parameter to main(), but
>> is there something better? Googling for "scala command line arguments"
>> and similar phrases yield many pages about getting the command-line
>> args, or about the arguments for Scala itself, but not doing things
>> like --foo, -f, etc.
>
> It doesn't do nearly everything one might want, but it does do some
> things you might want and some other things you might not know you want.
>
>  http://github.com/paulp/optional
>
> --
> Paul Phillips      | A Sunday school is a prison in which children do
> Vivid              | penance for the evil conscience of their parents.
> Empiricist         |     -- H. L. Mencken
> pull his pi pal!   |----------* http://www.improving.org/paulp/ *----------
>
>
>
> ________________________________
> This e-mail message (including any attachments) is for the sole use of
> the intended recipient(s) and may contain confidential and privileged
> information. If the reader of this message is not the intended
> recipient, you are hereby notified that any dissemination, distribution
> or copying of this message (including any attachments) is strictly
> prohibited.
>
> If you have received this message in error, please contact
> the sender by reply e-mail message and destroy all copies of the
> original message (including attachments).
>

Brian Clapper
Joined: 2009-05-18,
User offline. Last seen 42 years 45 weeks ago.
Re: Scala CLI Library?

Paul Phillips wrote:
> On Tue, Jan 19, 2010 at 09:46:04AM -0500, Joey Gibson wrote:
>> I may have just overlooked this, but I can't seem to find an answer
>> online. Is there a Scala library for processing command-line
>> arguments, similar to Getopts? I know that I can handle the
>> command-line args manually through the args parameter to main(), but
>> is there something better? Googling for "scala command line arguments"
>> and similar phrases yield many pages about getting the command-line
>> args, or about the arguments for Scala itself, but not doing things
>> like --foo, -f, etc.
>
> It doesn't do nearly everything one might want, but it does do some
> things you might want and some other things you might not know you want.
>
> http://github.com/paulp/optional

You can also use Java APIs. I use joptsimple, for instance.
http://jopt-simple.sourceforge.net/index.html

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland