Wiki

Ticket #12 (closed enhancement: fixed)

Opened 10 years ago

Last modified 9 years ago

Support specification of executable commandline args for cobra compile and execute

Reported by: hopscc Owned by: Chuck
Priority: medium Milestone:
Component: Cobra Compiler Version: 0.8.0
Keywords: Cc:

Description

As discussed in  CommandLine Arguments

Currently there is no way to pass args to the executable in a cobra compile and execute commandline, all args are taken as files to compile.

Modify compiler to support passing args as discussed.
(Note here first exact syntax to be implemented supporting
convenient single file compile-and-execute
single and multi file compile-and-execute noargs
single and multi file compile-and execute withargs
files file handling also)

Attachments

cmdlnArgs.patch Download (5.5 KB) - added by hopscc 10 years ago.
patches for fix (pass1) to tkt12
parseArgRefactor.patch Download (17.0 KB) - added by hopscc 10 years ago.
commandline parseArgs refactor
cmdLnArgs1.patch Download (23.0 KB) - added by hopscc 9 years ago.
compined patch of above plus tests
cmdLnArgsAll.patch Download (28.5 KB) - added by hopscc 9 years ago.
cmdlnArgs mods -run
cmdLnArgsAll.2.patch Download (28.5 KB) - added by hopscc 9 years ago.
cmdLnArgs-NEW-part1.patch Download (12.1 KB) - added by hopscc 9 years ago.
cmdLnArgs-NEW-part1and2.patch Download (15.0 KB) - added by hopscc 9 years ago.

Change History

Changed 10 years ago by hopscc

patches for fix (pass1) to tkt12

Changed 10 years ago by hopscc

Pass1 : add 2 new options, supporting changes and TODO on option lines for changes around -r and -run.

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.

More changes after refactor arg parsing code.

Changed 10 years ago by hopscc

commandline parseArgs refactor

Changed 10 years ago by hopscc

Second attachment is refactoring of parseArgs from 250 line code stream
schmeer to 80 lines of setup and helper invocation and helper function
definitions.
Now at least the main structure is apparent.

Changed 9 years ago by Chuck

The style for command line args is -foo-bar instead of -fooBar. Also, I've avoided capped single characters like X and will continue to do so unless there is some logic behind what the lowercase version means vs. the uppercase (and in this case I don't think there are even 2).

"run-args" and "exe-args" are not easy to distinguish based on their names. I think "exe-args" can be "run" in the D style where the next name after -run is the name of the program/main to run. No synonym for now.

I guess with "run-args" you're going after the -- convention that some programs use. I suppose that's convenient at the command line where you might hit UP and bang out "-- arg1 arg2 ENTER". And it's good for when people guess it. Let's call this one "run-args" to point out it's just the args for running that follow. -- would still be synonym and the common example usage. So:

    -run
    -run-args  (or)  --

Also, I'm not clear if this is two successive patches or the second subsumes the first.

For coding style, please use:

foo(x, y) instead of foo( x, y)
"x = y" instead of "x=y"

And use doc strings instead of "top comments".

Also, I don't see updates to Developer/IntRelNotes?.text

Does this patch handle "cobra prog arg1 arg2"?

That's lots of feedback, but if you apply it and submit a new patch (one from the top Workspace directory), I will apply it and we'll have all this for next release.

Changed 9 years ago by hopscc

  • owner changed from Chuck to hopscc
  • status changed from new to assigned

I'll redo the patch

-runArgs => -run-args (or --) ( == run-with-args-following)

-exeArgs => -exe-args -> -run (== execute-namedFile-with-args-following)
eventual synonym -r ( when -ref changed).

There were 2 patches here - the first did the min to implement the additional args.
the second refactored parseArgs and reimplemented the first. I wasnt sure if you'd take both in one big patch.

fixup the coding as mentioned.

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

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

Changed 9 years ago by hopscc

compined patch of above plus tests

Changed 9 years ago by hopscc

  • owner changed from hopscc to Chuck

Heres the modified patch as suggested
includes tests for new cmdline args.

Changed 9 years ago by Chuck

  • owner changed from Chuck to hopscc

Thanks for the new combined patch plus tests. I understand what you're saying about why you made the patches separate at first. I'll accept both at the same time.

Did you really mean to make the option called 'exec-args' (with a 'c') in the code? Both you and I were saying 'exe-args' (no 'c') in conversation.

But more importantly, I notice that the options specs contain all three of these: run, exec-args, run-args. Wouldn't it just be run and run-args?

Changed 9 years ago by hopscc

  • owner changed from hopscc to Chuck

Sorry yes shld have been exe-args - have been using just exec and had brain fart about what we'd agreed on. - will need to modify test file also...

The idea was that It Will become just run and run-args and the synonyms changed when
change -reference/-r... (theres some internal TODO comments to that effect)

Theres a slight semantic difference currently between -run ( default, compile and run) and eventual -run (current exec-args (run the given executable with given args ) and some position dependence (-run go anywhere/early in cmdline, -exec-args takes remaining args). Will need some more tweaking to meld these two properly (i.e handling -run <noArgs> to be same as
-run <name of compilation unit> and -run becomes a trailing or final option or whatever.
I wanted to get this patch out of the way before addressing what that should be since I havent thought very much about those effects

Changed 9 years ago by hopscc

cmdlnArgs mods -run

Changed 9 years ago by hopscc

Changed 9 years ago by hopscc

heres a patch for everything - all changes to date plus
- have -run do as -exe-args did
- compilePath and exeFileName path population from other if one is empty and other is not
- args/usage mods

- -reference synonym to -ref (from -r) and consequent test mods

- -run synonym as -r
- update to intermediate dev rel notes

Hope this is sufficient to finish this ticket.

Changed 9 years ago by hopscc

  • owner changed from Chuck to hopscc

Reassigned back to me pending result of patch for ticket#35
If accepted this patch should be redone against those changes since theres lots of
commonality.

Changed 9 years ago by hopscc

Right - we're at a stage where this can be redone.
1 Ignore all the above patches - they will fail with varying degrees of badly against the current src tree.

2. What I'm gonna do is reapply something like the previous changes against the current tree in two(2) patchesThe first will break existing commandline behaviour by removing -r as synonym for -reference and providing it only as (standalone) -r , new meaning "compile and run" for explicitly specifying the existing cobra default behaviour (counterpart to -c/compile).
I'll add -ref as shorthand for -reference (-ref/reference) - this should be pretty acceptable since recent augmentation of cobra use statement has relegated -r/ref/reference to niche usage anyway.
In addition this patch will add support for the (previous patches ) -run-args (synonym --) for specifying a list of args to pass to the executable when it runs.
This option is position dependent (must be last option on command line) since it sucks up all following args to pass onto executable.

This should be pretty non contentious since its what we have seemed to agree on in the previous discussion forum topic.

The second patch (as currently envisioned) will add support for a -run option that allows specification of both the executable to run AND its args if any. This too is position dependent since it too will suck up all following args. Providing both -run and --/run-args options is disallowed ( more specifically the first specified will be what takes precedence).
-run will remain separate from the (changed) -r option.

-r - action: compile and run (by default run the compiled executable) - implicit default action by cobra
-run - action: specify the executable and executable args to run after (successful) compilation.

The planned second patch is more contentious since its different than previously provided and different than discussed on the forum apart from my last few comments on the topic.

The second patch is a ways away so if you want more discussion on this please do it on the Forum topic ( commandline arguments)

Changed 9 years ago by hopscc

Changed 9 years ago by hopscc

patch for stage1 of changes as listed.
-r now on -run
-ref on -reference
-run-args/--) remainder args passed to executable

.. Goanna have to rethink stage 2 since I'd forgotten that -run was also currently a command
options - rename -run to something else ( -run-after-compile, -r) (:-(

  • use a different option for specifying executable and args ( -cmd, -runcmd/rc, -rrun/rr, -exe, -run-next/run-exec/runn)
  • put up with inconsistency in implicit vs explicit use of -run

Can apply this anytime U like chuck, stage2 wont be very much code...

Changed 9 years ago by hopscc

I'll do stage2 patch such that

-run specifies executable and args
-r is synonym for old -run cmd renamed to 'run-exe'

i.e old -run -> -run-exe

This will also be a break with previous cmdline arg compatibility - if for some reason anyone had got used to explicitly specifying -run you're goanna get a little surprise.

Changed 9 years ago by hopscc

Changed 9 years ago by hopscc

  • owner changed from hopscc to Chuck

Latetst patch provides both part1 and new part2 capabilities as described:
old -run becomes -run-exe (break from previous behaviour)
-r synonym remains on -run-exe
new -run specifies executable file and args to pass to it
added test for new -run option
augmented relnotes

changes pass all tests.
(If dislike -run-exe as choice of command name replacing old -run
feel free to change as desired - its use is all in CommandLine.cobra, theres no test for it)

Just to reiterate this patch causes two breaks from previous behaviour cmdline options
old -run -> -run-exe
old -r (synonym for -reference) -> synonym for -run-exe.

I would really like it if I never have to touch this ticket again.

Changed 9 years ago by Chuck

See comments at

 http://cobra-language.com/forums/viewtopic.php?f=4&t=63&p=941#p941

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.

Changed 9 years ago by Chuck

Applied cmdLnArgs-NEW-part1.patch per our discussion

changeset:1673

Changed 9 years ago by hopscc

Cool. Is this closable now?

Changed 9 years ago by Chuck

  • status changed from assigned to closed
  • resolution set to fixed

Yes, closing.

I broke out the remaining item to ticket:55

Note: See TracTickets for help on using tickets.