Ticket #12: cmdLnArgs-NEW-part1.patch
File cmdLnArgs-NEW-part1.patch, 12.1 KB (added by hopscc, 16 years ago) |
---|
-
HowTo/600-AccessMySQL.cobra
1 1 # .require. MySql.Data.dll 2 # .args. -r :System.Data -r:MySql.Data2 # .args. -ref:System.Data -ref:MySql.Data 3 3 """ 4 4 See also: 5 5 docs/mysql on the Cobra web site … … 11 11 http://dev.mysql.com/doc/refman/5.0/en/connector-net-installation-unix.html 12 12 13 13 To run: 14 cobra -r :System.Data -r:MySql.Data AccessMySQL.cobra14 cobra -ref:System.Data -ref:MySql.Data AccessMySQL.cobra 15 15 16 16 Or just compile: 17 cobra -c -r :System.Data -r:MySql.Data AccessMySQL.cobra17 cobra -c -ref:System.Data -ref:MySql.Data AccessMySQL.cobra 18 18 and then run: 19 19 mono mysql.exe 20 20 21 You can probably leave out the "-r :<library>" and rely of `use` to locate these.21 You can probably leave out the "-ref:<library>" and rely of `use` to locate these. 22 22 23 23 Mac OS X: 24 24 For installation, MySQL docs say "Copy the MySql.Data.dll file to your Mono project installation folder." -
Source/Compiler.cobra
482 482 483 483 484 484 def runProcess as Process 485 return .runProcess(nil, nil) 486 487 def runProcess(exeName as String?, argList as List<of String>?) as Process 485 488 """ 486 489 Returns a new Process with startInfo.fileName and p.startInfo.arguments set appropriately 487 for the produced executable and the current options .490 for the produced executable and the current options and any provided argslist. 488 491 """ 489 # TODO: support args to the program with a - or -- separator490 492 p = Process() 493 baseExeFileName = exeName ? .baseExeFileName 494 fullExeFileName = exeName ? .fullExeFileName 491 495 branch .platform 492 496 on PlatformEnum.Microsoft 493 p.startInfo.fileName = .baseExeFileName497 p.startInfo.fileName = baseExeFileName 494 498 on PlatformEnum.Novell 495 499 p.startInfo.fileName = 'mono' 496 500 args = '' 497 501 # mono also needs --debug when running 498 502 if .options.getDefault('debug', '') not in ['', '-'] 499 503 args += '--debug ' 500 args += '"[ .fullExeFileName]"'504 args += '"[fullExeFileName]"' 501 505 p.startInfo.arguments = args 502 506 else 503 507 throw FallThroughException(.platform) 508 509 if argList and argList.count 510 args = p.startInfo.arguments ? '' 511 args += Utils.join(' ', argList) 512 p.startInfo.arguments = args 504 513 return p 505 514 506 515 ## … … 751 760 print ' |', line 752 761 return refs 753 762 754 parts = output.replace('-r :', '\0').split(c'\0')763 parts = output.replace('-ref:', '\0').split(c'\0') 755 764 for part in parts 756 765 if part.trim <> '', refs.add(part.trim) 757 766 -
Source/CommandLine.cobra
199 199 }, 200 200 { 201 201 'name': 'reference', 202 'synonyms': ['r '], # TODO: lose 'r' ->'Ref', 'R', something else202 'synonyms': ['ref'], 203 203 'isAccumulator': true, 204 204 'description': 'Add a DLL reference.', 205 205 'args': 'Some.dll', … … 218 218 # 'args': ':Qualified.Type.Name', 219 219 # }, 220 220 { 221 'name': 'run', # TODO: Synonym 'r' after change 'reference' switch 221 'name': 'run', # this is a switch only 222 'synonyms': ['r'], 222 223 'description': 'Runs the Cobra program. This is the default behavior if specify any Cobra source files.', 223 224 'type': 'main', 224 225 }, 226 { 227 'name': 'run-args', 228 'synonyms': ['-'], # '--' 229 'description': 'Remaining args are to be passed to executable.', 230 'eg': '-- arg1 arg2 argThree', 231 'type': 'args-list', 232 }, 225 233 { 226 234 'name': 'sharp-compiler', 227 235 'description': 'Specify the path to the backend C# compiler.', … … 485 493 if .options.boolValue('compile') # maybe changed by compiler directive 486 494 return 487 495 488 p = c.runProcess 496 exeFileName as String? = nil 497 runArgs = .options.getDefaultLOStr('run-args') 498 # exeArgs = .options.getDefaultLOStr('exe-args') 499 # if exeArgs.count 500 # exeFileName = exeArgs[0] 501 # runArgs = exeArgs[1:] 502 p = c.runProcess(exeFileName, runArgs) 489 503 if _verbosity >= 1 490 504 print 'Running: [p.startInfo.fileName] [p.startInfo.arguments]' 491 505 print .verboseLineSeparator … … 635 649 valueStr = 'no-value' 636 650 fileList = List<of String>() 637 651 mainOptions = List<of String>() 652 argn = 0 638 653 for arg in args 639 if not arg.trim.length640 641 654 argn += 1 # ofset next arg after current 655 if not arg.trim.length, continue 656 642 657 isOption = arg.startsWith(optionPrefix) 643 658 if isOption 644 659 name = _getOptionParts(arg, optionPrefix, out valueStr) … … 649 664 continue 650 665 651 666 value = _processToValue(name, valueStr, spec, mainOptions) 667 if value == 'args-list' 668 value = args[argn:] 652 669 if value is nil 653 670 _error('Cannot process value "[valueStr]" for option "[name]".') 654 671 valueDict[name] = value to ! 655 672 didSpecify[name] = true 673 if spec['type'] to String == 'args-list' 674 break # absorbed remainder of args 656 675 else # not isOption 657 676 if _optsOnly 658 677 _error("Filenames are not allowed here, All the args provided must be '-' prefixed options") … … 691 710 """ 692 711 while arg.startsWith(optionPrefix) 693 712 arg = arg[1:] 713 if not arg.length # '--' 714 arg = 'run-args' 694 715 return arg 695 716 696 717 def splitOpt(arg as String) as IList<of String> … … 799 820 on 'main' 800 821 mainOptions.add(name) 801 822 value = true 823 on 'args-list' # remainder of args are for execution of exe file 824 value = 'args-list' 802 825 else 803 826 value = _interpretValue(valueStr, spec) 804 827 return value … … 953 976 print ' cobra <options> <command> <path(s)>' 954 977 print ' * commands that operate on path(s) are:' 955 978 print ' -compile ... Compile only. Also, -c' 956 print ' -run ....... Run the program (compile if necessary). '979 print ' -run ....... Run the program (compile if necessary). Also -r (Default)' 957 980 print ' -test ...... Run the unit tests of a library.' 958 981 print ' -document .. Document the program (partial compilation). Also, -doc' 959 982 print '' -
Tests/720-libraries/100-winforms/100-winforms.cobra
1 1 # .compile-only. 2 # .args. -c -t:winexe -r :System.Windows.Forms2 # .args. -c -t:winexe -ref:System.Windows.Forms 3 3 4 4 use System.Windows.Forms 5 5 -
Tests/320-misc-two/520-indexer-with-non-standard-name.cobra
1 # .args. -r :System.Xml1 # .args. -ref:System.Xml 2 2 3 3 # XmlNodeList has an ItemOf property instead of Item. 4 4 # This test shows that Cobra is reading the DefaultMemberAttribute of the class. -
Tests/700-command-line/705-run-args.cobra
1 # Test compile+run execution specifying args to run compiled prog with 2 class Test 3 def main is shared 4 p as System.Diagnostics.Process? 5 cobraPath = CobraCore.findCobraExe 6 assert cobraPath 7 if cobraPath 8 cmdln = "702-echo -- argA argB argC" 9 output = CobraCore.runCobraExe(cobraPath, cmdln, out p) 10 #print output 11 assert 'Unhandled Exception' not in output 12 assert 'argA argB argC' in output 13 assert p.exitCode == 0 14 15 cmdln = "702-echo -run-args x1arg1 x1argB x1argC" 16 output = CobraCore.runCobraExe(cobraPath, cmdln, out p) 17 #print output 18 assert 'Unhandled Exception' not in output 19 assert 'x1arg1 x1argB x1argC' in output 20 assert p.exitCode == 0 21 22 cmdln = "-r 702-echo -run-args x2arg1 x2argB x2argC" 23 output = CobraCore.runCobraExe(cobraPath, cmdln, out p) 24 #print output 25 assert 'Unhandled Exception' not in output 26 assert 'x2arg1 x2argB x2argC' in output 27 assert p.exitCode == 0 28 -
Tests/700-command-line/812-lib-option.cobra
1 1 # was .args. -lib:libdir -r:foolib -c 2 %% args -lib:libdir -r :foolib -c2 %% args -lib:libdir -ref:foolib -c 3 3 4 4 class Test 5 5 -
Tests/700-command-line/300-args-reference-gac-lib.cobra
1 # .args. -r :System.Xml1 # .args. -ref:System.Xml 2 2 3 3 use System.Xml 4 4 -
Tests/700-command-line/402-fooprog.cobra
1 # .args. -embed-run-time:no -r :400-foolib.dll1 # .args. -embed-run-time:no -ref:400-foolib.dll 2 2 3 3 class Program 4 4 -
Tests/700-command-line/404-fooprog.cobra
1 # .args. -embed-run-time:no -r :400-foolib1 # .args. -embed-run-time:no -ref:400-foolib 2 2 3 3 # same as other fooprog, but the -r arg does not include the ".dll" extension -- both ways should work 4 4 -
Tests/700-command-line/410-use-lowernames-dll.cobra
1 # .args. -r :lowernames.dll1 # .args. -ref:lowernames.dll 2 2 3 3 class Program 4 4 -
Tests/700-command-line/512-lib-option.cobra
1 1 # .compile-only. 2 # .args. -lib:libdir -r :foolib -c2 # .args. -lib:libdir -ref:foolib -c 3 3 4 4 class Test 5 5 -
Tests/700-command-line/702-echo.cobra
1 # .skip. 2 class Echo 3 def main is shared 4 args = CobraCore.commandLineArgs 5 sep='' 6 for a in args[1:] 7 print '[sep][a]' stop 8 sep=' ' 9 print -
Developer/IntermediateReleaseNotes.text
1 1 Post 0.8 2 2 3 * Modified commandline options so -r becomes synonym for -run rather 4 than for -reference. -reference synonym becomes -ref. 5 Support -run-args (synonym --) option for specifying args to pass to compiled executable 6 3 7 * Added support for "multi-arg assignment" which allows you to assign to a number of variables from contents of a list in one statement 4 8 .code 5 9 a,b,c = ['val1', 'val2', 'val3'] 6 10 7 8 11 * Added support for a new compiler directive 'args' that takes command line options and applies them to the compilation environment from that point on. 9 12 .code 10 13 %% args -target:lib -embed-run-time:no