If you want to use your "arg" get code, you can:

    USE: command-line

    : main ( -- )
        command-line get parse-command-line "help" get . ;

In this case, "command-line" is the list of arguments to your script.

Best,
John.


On Sat, Aug 20, 2011 at 9:42 AM, Andrew Pennebaker <
[email protected]> wrote:

> Okay, factor -help ios7crypt.factor works. It seems Factor ignores
> arguments after the first script name.
>
> How can I rearrange the shebang so that ./ios7crypt.factor -help sends the
> argument to factor after the script name?
>
> For example, in Common Lisp a multilineshebang rearranges arguments so that
> the script name is forcibly passed twice:
>
> #!/bin/bash
> #|
> exec clisp -q -q $0 $0 ${1+"$@"}
> exit
> |#
>
> If there's a way to do multiline shebangs in Factor, then ./ios7crypt.factor
> -help can be run correctly.
>
> Cheers,
>
> Andrew Pennebaker
> www.yellosoft.us
>
> On Sat, Aug 20, 2011 at 12:37 PM, Andrew Pennebaker <
> [email protected]> wrote:
>
>> 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
>
>
------------------------------------------------------------------------------
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