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 » Thu Oct 16, 2008 7:29 am

The old -run ( and new -run-exe) was a cmd - telling cobra to take the thing just compiled and run it - or run the thing after compiling it (no args)
the new run is only an executable-to-run-and-args specifier. it specifies args not an action. The two are (still) decoupled
i.e the default simple case
Code: Select all
cobra x.cobra  #compile x.cobra to x,exe, run x.exe with no args

can be thought of as this cmd line with everything explicit
Code: Select all
cobra -run-exe x.cobra -run x.exe

more complicated cases ( multi file compile and multi args to the executable to run) fall/follow out of that
also
the new -run is position sensitive - it needs to be the last option on the cmdline ( since it sucks all remaining args)
the old one has no such dependency ( nor does -run-exe)

A file wouldnt be specified twice (unless you wanted to be really explicit) - normally you'd use the -run-args option - at least thats what I've been doing mostly
Code: Select all
cobra x.cobra -run-args a b c
cobra x.cobra -- a b c


I expect there could be more defaulting and arg shifting so that a single unspecified compile file could be inferred from the first option of the -run arglist ,
or preclude cobra from running an arbitrary executable by adding the executable ( name suitably modded) to the front of the compile file list
if it wasnt already there or any number of other things.
This patch (none of these patches) do that or have ever done that.
Its probable that if the intention was to support what D does then this change ( -run, -run-args) was the first step to that and it never got beyond ( or even to) that.

I imagine the only real use for this (-run executable args) as it currently stands would be when building a referenced library that you wanted to test run against
(ask dennis what he was thinking when he requested this) but maybe I just havent come across the right set of build/run cases yet.
I've not ever used it apart from making everything that I want to happen really explicit.

The example with -t was assuming the prior existnce of a executable (x.exe) that referenced the lib being built ( and found it where cobra left it after the compilation) so no the compile step still only builds the lib ( xlib.dll)

As originally presented/implemented the compile step built an executable from a set of files and the execute step ran that executable.
The (new) -run option decouples those so that you can possibly run something other than the thing just built
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Command Line Arguments

Postby Charles » Thu Oct 16, 2008 6:08 pm

This behavior feels very unfamiliar to me. I don't recall us agreeing to a command to arbitrarily run another program. I also don't think Dennis requested that. I think he requested that he be able to say:
Code: Select all
cobra libfile1 libfile2 -run progfile arg1 arg2

Also, my earlier examples were possibly misleading when they used names like "lib1", "lib2" and "prog" because they sometimes implied which file had to have the .main method when sometimes that did not matter. For example, in "cobra -c foo bar baz", it doesn't matter which of foo, bar and baz is "the program".

Here is a new spec. Feedback is welcome.

cobra <progfile>
# compiles and runs <progfile>

cobra <progfile> <arg1> <arg2>
# compiles and runs <progfile>, passing the <args> as arguments

cobra <cobrafile1> <cobrafile2> -- <arg1> <arg2>
# compiles and runs the <cobrafiles>, passing <args> as arguments to the resulting executable

cobra -c <cobrafile1> <cobrafile2>
# compiles all and runs nothing. there can be no arguments passed on to the resulting executable, because this is compilation only

cobra <libfile1> <libfile2> -run <progfile> <arg1> <arg2>
# compiles and runs passing everything after <progfile> as arguments to the resulting executable
# ideally you could have multiple .main methods in your code base and -run serves to specify that the .main in <progfile> is the designated main entry

# of course, nothing prevents you from being explicit:
cobra -run <progfile> <args>
cobra -compile <cobrafiles>

The argument directly after -run is a Cobra source file containing a .main method.

-test is somewhat like -run except that:
* it works on both libraries and programs
* it replaces the .main of a program
* it prints the progress of running the tests
* like -compile, its position is not important

-test, -compile and -run are mutually exclusive. Using more than one of them is an error.

Options like -debug, -optimize and -turbo are independent of these.

Synonyms:
-run -r
-compile -c
-run-args --
-reference -ref
-target -t

There is no option to run an arbitrary filebased .exe/.bat/script after compilation. Instead you can:
* enter the command on the next line
* use a semicolon and add the command
* write a batch file or script file to facilitate that

There are no options called -run-exe or -X.

If I've missed something, please speak up. Or if you think there is something that is awkward to do under this design, or anything else wrong about the design.
Charles
 
Posts: 2513
Location: Los Angeles, CA

Re: Command Line Arguments

Postby hopscc » Fri Oct 17, 2008 12:29 am

... I have no words for what I feel about going through this again.

I dont know what dennis wanted, I dont know what you wanted , all I know is that what I read in
Code: Select all
cobra <whatever> -run <progfile> <whatever>

was that the thing after the '-run' was to be executed and was therefore an executable and thats what has been implemented from the very first patch
and what was described in the first discussion item after the patch and what has never been even mentioned till now.

Looking back on the discussion items I've posted here its now obvious I've been conversing with myself

>If I've missed something, please speak up. Or if you think there is something that is awkward to do under this design, or anything else wrong about the design.
Thats a big yes to all 3

Its driving me nuts to try and do it in this stupid unquotable slow character eating web interface - I'll send email
..
As a placeholder you'll get 90% of what you mention if you apply the last but one patch (cmdLnArgs-NEW-part1.patch ). That way too theres a better base to work from
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Command Line Arguments

Postby Charles » Fri Oct 17, 2008 12:39 am

I said on the ticket "Most important is to hammer out the spec. I don't care if it's then you or I that hammer Cobra to support it." so you don't have to do anything again. Sorry for not including that in my forum post as well.

While it's correct that the thing after -run was to be executed, the context was that source files were being passed to Cobra.

Regarding your "conversing with myself", sometimes I just don't understand you. For example, one of the previous posts said:

"This patch (none of these patches) do that or have ever done that."

Even in the context of the message, I just couldn't tell what that meant. You lose me a lot.

I'll take a look at the patch you mention. Let me know if anything is missing or undesirable in the spec above.

And if you want, I can take it from here in terms of coding.
Charles
 
Posts: 2513
Location: Los Angeles, CA

Re: Command Line Arguments

Postby hopscc » Fri Oct 17, 2008 1:55 am

1) read your email - writeup should have got there by now.

2) 'context was src files passed to cobra'
yes I get that Now since you have just explicitl\y mentioned it - I didnt get it back in Februrary nor in the intervening months, initial patch, subsequent repatches or interim posts
this is obviously my fault. ( thats just a trace of sarcasm)

3) conversing with myself
read the posts - theres no followup of my descriptions or of what was in the patches ( which was running a named executable file, not a .main src)

'This patch(none of these patches)' = The last patch and all the patches on the ticket
'do that or have ever done that' refers to the this:
"I expect there could be more defaulting and arg shifting so that a single unspecified compile file could be inferred from the first option of the -run arglist ,
or preclude cobra from running an arbitrary executable by adding the executable ( name suitably modded) to the front of the compile file list
if it wasnt already there or any number of other things."
this is refering to the
Code: Select all
cobra lib lib -run prog args
form and handling you mentioned previously
here I'm thinking in context of my implementation that keeps separate the list of file to compile and the args for the .exe invocation

'you lose me a lot'
sorry but I cant tell unless you ask for clarification.

re the rest its in your email (hopefully)
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Command Line Arguments

Postby Charles » Fri Oct 17, 2008 2:24 am

Spec refinement. Where I said:

# of course, nothing prevents you from being explicit:
cobra -run <progfile> <args>
cobra -compile <cobrafiles>

It should have been:

# of course, nothing prevents you from being explicit:
cobra -compile <cobrafiles>

Also, it's been suggested that we don't need the D-like behavior for -run:

cobra <libfile1> <libfile2> -run <progfile> <args>

if we have:

cobra <sourcefiles> -- <args>

and I'm inclined to agree that -- is sufficient.

I'll try to provide feedback in a more timely fashion, and speak up when I don't understand comments on tickets and forum posts,

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

Re: Command Line Arguments

Postby Charles » Fri Oct 17, 2008 4:12 am

I have applied applied cmdLnArgs-NEW-part1.patch of ticket:12.

See changeset:1673

We can now say:

cobra <sourcefiles> -- <args>

Thanks,
Chuck
Charles
 
Posts: 2513
Location: Los Angeles, CA

Previous

Return to Discussion

Who is online

Users browsing this forum: No registered users and 12 guests

cron