Forums

Command Line Arguments

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Re: Command Line Arguments

Postby hopscc » Tue May 06, 2008 6:13 am

I've added a patch file to http://cobra-language.com/trac/cobra/ticket/12 (Trac Ticket 12) that addresses both of these though not exactly as discussed above.

It adds support for two new options
* -runArgs (synonym '--) slurps up rest of args and passes them onto run executable as its cmdline args
* -exeArgs (synonym '-X' temporarily ) slurps up rest of args; treats first one as name of executable to run, remainder as its cmdline args.
and TODOs for changes to -ref and -run options

I expect -runArgs to be mostly used via '--' and -exeArgs to be used via '-X';
when -run becomes -r and -r(ef) becomes [something else - -ref, -R,?] , -X/-runArgs can become -run.

giving (Chucks current thinking examples)
Code: Select all
    cobra prog
    # compiles and runs foo
    # UNCHANGED

    cobra prog -- foo bar
    # compiles and runs prog, passing foo and bar as arguments
    # ++ args passed with '--' (or '-runArgs')

    cobra -c prog lib1 lib2
    # compiles all. there can be no arguments passed on, because this is compilation only
    # AS-IS

    cobra lib1 lib2 -X prog foo bar
( will become)
    cobra lib1 lib2 -run prog foo bar
    # compiles and runs passing everything after prog as arguments (to prog executable)

    # of course, nothing prevents you from being explicit:
    cobra -X prog
    # patch doesnt address this - have to do
    # cobra -run prog -- args
    # will become -run prog
    cobra -c prog
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Command Line Arguments

Postby hopscc » Sun Jul 13, 2008 4:56 am

Duplicate and expansion of reply in ticket.
Redo patch such that
-runArgs => -run-args (or --) ( means run-with-args-following)

-exeArgs => -exe-args -> -run (means execute-namedFile-with-args-following)
eventual synonym -r ( when -ref changed).
the -X (big eXecute) is temporary pending availability of -r (as mentioned in the discussion)

fixup the coding as mentioned.

There were 2 patches provided - the first did the min to implement something providing the the additional capability
the second refactored parseArgs and reimplemented the first. I wasnt sure if you'd take both in one big patch.
The third was to be any reworking for -libs/-reference changes when nailed down and modified cobra prog args syntax.




re "cobra prog arg1 arg2"
No not yet. ( see the discussion) The equivalent for this patch is
Code: Select all
cobra prog -- arg1 arg2


I vaguely remember I needed the refactoring accepted before attempting remangling to accept
(if poss) the above syntax.

Can you give some indication of what you think -reference (current synonym -r) will become ?
postulated -R or -ref but that was just a blind stab. ( -cr == c#Reference ????)
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Command Line Arguments

Postby Charles » Mon Jul 14, 2008 2:14 am

I haven't fully digested your response yet, but in answer to your last question, I was thinking -reference/-ref. (And -run/-r and -compile/-c)
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Command Line Arguments

Postby hopscc » Mon Jul 14, 2008 5:53 am

OK - I'll be doing the update to that patch next
DO you want to have the -r/reference changed now (same patch) or do you want to leave it for the future sometime?
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Command Line Arguments

Postby hopscc » Tue Jul 22, 2008 4:42 am

Latest patch on ticket should have all changes as discussed to date around this plus
changes for moving -r synonym off -reference and onto -run. -reference synonym becomes -ref,
(-exe-args is out)
(ignore the double patch - they shld be both the same - browser crash).

I've used this some now and to me it seems a bit clumsy
-run is now a command flag (compile and run) and an option switch introducing the exe and cmdline args (when used in that way it becomes position sensitive)
which nothing else is......
It feels cleaner to keep -run as was and move -r onto equiv of (old) -exe-args option - keeping run-and-compile and
explicit run-what-with-what separates/--
FWIW my common edit-compile workflow has hardly used this at all - more usually single or multi files to compile and -run-args/-- args passed to executable.

I'm not happy with the usage description for this either - it doesnt explain what it does well or completely ( i.e no description of the
cobra <options> <optional paths> <runargs> form).
Unfortunately I couldnt get any wording that covered everything cleanly....
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Command Line Arguments

Postby Charles » Tue Jul 22, 2008 5:22 pm

I'll take a look and get back.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Command Line Arguments

Postby hopscc » Wed Oct 15, 2008 2:31 am

It lives!!!

New patches coming. see ticket#12
-r moves from synonym for -reference to its own option (-r) meaning "compile-and-run" ( by default whats just been compiled)
-reference gets new synonym -ref
.. This breaks/changes existing cmdline option behaviour
--/-run-args to specify a list of args to pass to the executable , must be last option on the cmdline since it sucks up (uninterpreted) all remaining args.
This is pretty much as previously discussed and patched.


Follow on patch to be applied on top of above.
add separate -run option that specifies executable file and args to pass to it after successful compilation - no linkage to (new) -r from above patch
must be last option on the cmdline since it sucks up (uninterpreted) all remaining args
(slightly different than previously discussed - done this way in light of my previous comments).

Add to any follow on discussion if interested and have different opinion/Desires for the second patch

This will allow
Code: Select all
cobra -c x.cobra # compile x.cobra only
cobra -r x.cobra # compile and run (explicitly) x.cobra ( no args )
cobra x.cobra # compile and run x.cobra

cobra -ref:foo.Bart x.cobra # compile x.cobra specifying reference on cmdline
 
cobra x.cobra -- a  b c # compile and run x.cobra passing  args a b c
cobra x.cobra -run-args a  b c # compile and run x.cobra passing  args a b c
cobra x.cobra y.cobra -- a b c # compile x,cobra + y.cobra, run resulting executable with args a b c

cobra x.cobra -run x a b c  # compile x.cobra and execute x.exe passing args a b c

# build lib then test run (presumably using it)
cobra -t:lib xlib.cobra -run x a b c # compile xlib.cobra to lib then execute x.exe passing args a b c
cobra -t:lib xl.cobra y.cobra z.cobra -run xtest a  b c # compile multifiles to lib and test run with args

cobra x.cobra y.cobra z.cobra -run x a b c # compile multi files to executable and run specifying executable explicitly with args a b c
cobra x.cobra y.cobra z.cobra -- a b c # same as above except implicit executable


-- "There is no final word"
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Command Line Arguments

Postby Charles » Wed Oct 15, 2008 1:37 pm

Cool. I'm probably off for the rest of today, so I'll look at this tomorrow.

-Chuck
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Command Line Arguments

Postby hopscc » Wed Oct 15, 2008 10:07 pm

Posted second patch for providing part2. Includes contents of part1 as well.

I went with using -run for exec+args as discussed and renamed old -run cmd to -run-exe.
Think this should be pretty transparent as I'd imagine most common use is to rely on default ( for compile+run) or
specify the (new) -r synonym ( cf -c) ...
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Command Line Arguments

Postby Charles » Thu Oct 16, 2008 4:06 am

I have the patch applied in a workspace, but have some questions.

I'm tired, so maybe I'm just not getting this, but what's the difference between the old -run now named -run-exe and the new -run? Can you give contrasting examples next to each other?

Also, why would a file be specified twice?:
Code: Select all
cobra x.cobra -run x a b c  # compile x.cobra and execute x.exe passing args a b c

# shouldn't that be:
cobra -run x a b c
# ?
# and if you had multiple files:
cobra file1 file2 -run file3 arg1 arg2 arg3

I thought that's how D did it and we were going to support that.

In your examples above, how is -t: and -run working at the same time? Is Cobra producing both the xlib.dll and the x.exe in response to the same command line?
Charles
 
Posts: 2515
Location: Los Angeles, CA

PreviousNext

Return to Discussion

Who is online

Users browsing this forum: No registered users and 104 guests