This works in the interpreter, but I'm having trouble passing command line
arguments to my scripts. For some reason, Factor isn't setting the global
variable "help" when I pass it "-help".

$ cat ios7crypt.factor
#! /usr/bin/env factor

USING: kernel namespaces io prettyprint ;
IN: ios7crypt

: usage ( -- )
    "Usage: ios7crypt.factor [options]" print
    "-encrypt <password>" print
    "-decrypt <hash>" print
    "-test" print
    "-help" print ;

: main ( -- ) "help" get . ;

MAIN: main

$ ./ios7crypt.factor
Loading /Users/andrew/.factor-rc
f

$ ./ios7crypt.factor -help
Loading /Users/andrew/.factor-rc
f

Cheers,

Andrew Pennebaker
www.yellosoft.us

On Thu, Aug 18, 2011 at 1:50 AM, Joe Groff <[email protected]> wrote:

>
> On Aug 17, 2011, at 10:32 PM, Andrew Pennebaker wrote:
>
> Awesome!
>
> By the way, I don't get any usage info for Factor that would list the
> -script option. (no factor -h, factor --help, etc.) Is there a getopt for
> Factor?
>
>
> I think -script was a relic of the past; it doesn't appear to be necessary
> anymore. The main remaining caveat with #! is that it needs to be followed
> by whitespace.
>
> There might be a getopt-like parser library, but I don't know of it. Maybe
> someone else does. However, the VM will parse options of the form -foo or
> -foo=bar and set them as variables in the global namespace for you, which
> you can access with the get function. For example:
>
> $ ./factor -foo -zim=zang -flux=rad
> ( scratchpad ) "foo" get .
> t
> ( scratchpad ) "zim" get .
> "zang"
> ( scratchpad ) "flux" get .
> "rad"
>
> -Joe
>
>
> ------------------------------------------------------------------------------
> Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
> user administration capabilities and model configuration. Take
> the hassle out of deploying and managing Subversion and the
> tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
> _______________________________________________
> Factor-talk mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to