Ticket #12: cmdlnArgs.patch
File cmdlnArgs.patch, 5.5 KB (added by hopscc, 17 years ago) |
---|
patches for fix (pass1) to tkt12 |
-
Compiler.cobra
392 392 assert modules.count 393 393 _modules.addRange(modules) 394 394 return modules 395 395 396 # default invocation of runProcess - no explicit exeName and no argList 396 397 def runProcess as Process 398 return .runProcess(nil, nil) 399 400 # runProcess passing optional explicit exeName and argList 401 def runProcess(exeName as String?, argList as IList<of String>?) as Process 397 402 """ 398 403 Returns a new Process with startInfo.fileName and p.startInfo.arguments set appropriately 399 for the produced executable and the current options .404 for the produced executable and the current options and any provided arglist. 400 405 """ 401 # TODO: support args to the program with a - or -- separator402 406 p = Process() 407 if exeName 408 baseExeFileName = exeName 409 fullExeFileName = exeName 410 else 411 baseExeFileName = .baseExeFileName 412 fullExeFileName = .fullExeFileName 403 413 branch .platform 404 414 on PlatformEnum.Microsoft 405 p.startInfo.fileName = .baseExeFileName415 p.startInfo.fileName = baseExeFileName 406 416 on PlatformEnum.Novell 417 # fixup fullExeFileName 418 if not '.' in fullExeFileName 419 fullExeFileName += '.exe' 407 420 p.startInfo.fileName = 'mono' 408 421 args = '' 409 422 # mono also needs --debug when running 410 423 if .options.getDefault('debug', '') not in ['', '-'] 411 424 args += '--debug ' 412 args += '"[ .fullExeFileName]"'425 args += '"[fullExeFileName]"' 413 426 p.startInfo.arguments = args 414 427 else 415 428 throw FallThroughException(.platform) 429 430 if argList 431 args = p.startInfo.arguments ? '' 432 # for a in argList 433 # args += ' [a]' 434 args += Utils.join(' ', argList) 435 p.startInfo.arguments = args 436 416 437 return p 417 438 418 439 ## -
CommandLine.cobra
195 195 }, 196 196 { 197 197 'name': 'reference', 198 'synonyms': ['r'], 198 'synonyms': ['r'], # TODO: lose 'r' ->'Ref', 'R', something else 199 199 'isAccumulator': true, 200 200 'description': 'Add a DLL reference.', 201 201 'args': 'Some.dll', … … 214 214 # 'args': ':Qualified.Type.Name', 215 215 # }, 216 216 { 217 'name': 'run', 217 'name': 'run', # TODO: Synonym 'r' after change 'reference' switch 218 218 'description': 'Runs the Cobra program. This is the default behavior if specify any Cobra source files.', 219 219 'type': 'main', 220 220 }, 221 # 222 { 223 'name': 'exeArgs', # TODO: -> 'run' after change 'run' to 'r' 224 'synonyms': ['X'], 225 'description': 'Remaining args are name of the file to run and args to pass to it.', 226 'eg': '-X echo arg1 arg2 argThree', 227 'type': 'exeArgs', 228 }, 229 # 230 # 231 { 232 'name': 'runArgs', 233 'synonyms': ['-'], #'--' 234 'description': 'Remaining args are to be passed to executable.', 235 'eg': '-- arg1 arg2 argThree', 236 'type': 'runArgs', 237 }, 238 # 221 239 { 222 240 'name': 'sharp-compiler', 223 241 'description': 'Specify the path to the backend C# compiler.', … … 281 299 282 300 var _options = Options() 283 301 var _pathList as List<of String>? 302 var _runArgs as IList<of String>? # nil or args set for running exe 303 var _exeFileName as String? # Name specified for exe to run 284 304 var _htmlWriter as HtmlWriter? 285 305 286 306 def init … … 395 415 ensure 396 416 options 397 417 paths 398 body 418 body # TODO: refactor to something more modular (i.e much < 200 lines long) 399 419 optionPrefix = '-' 400 420 valuePrefix = c':' 401 421 if not args.count … … 432 452 value = 'no-value' to dynamic 433 453 mainOptions = List<of String>() 434 454 didSpecify = Dictionary<of String, bool>() # CC: could just be a Set 455 argn=0 435 456 for arg in args 457 argn += 1 # next arg after current 436 458 if arg.trim.length == 0 437 459 continue 460 438 461 if arg.startsWith(optionPrefix) 439 462 isOption = true 440 463 while arg.startsWith(optionPrefix) 441 464 arg = arg[1:] 465 if not arg.length # '--' 466 arg='runArgs' 442 467 else 443 468 isOption = false 444 469 if isOption … … 489 514 if spec['type'] == 'main' 490 515 mainOptions.add(name) 491 516 value = true 517 else if spec['type'] == 'runArgs' 518 # remainder of args are for execution of exe file 519 _runArgs = args[argn:] 520 break 521 else if spec['type'] == 'exeArgs' 522 # remainder of args are exe file and then args for it 523 if args.count <= argn 524 .error("exeArgs option must have at least one arg following") 525 _exeFileName = args[argn] 526 _runArgs = args[argn+1:] 527 break 492 528 else 493 529 possible = .interpretValue(valueStr, spec) 494 530 if possible is not nil … … 584 620 options['include-nil-checks'] = false 585 621 options['include-tests'] = false 586 622 options['optimize'] = true 587 623 588 624 def interpretValue(valueStr as String, spec as Dictionary<of String, Object>) as dynamic? 589 625 value as dynamic? 590 626 branch spec['type'] to String … … 710 746 if c.errors.count 711 747 print 'Not running due to errors above.' 712 748 else 713 p = c.runProcess 749 p = c.runProcess(_exeFileName, _runArgs) 714 750 if _verbosity >= 1 715 751 print 'Running: [p.startInfo.fileName] [p.startInfo.arguments]' 716 752 print .verboseLineSeparator … … 821 857 first = false 822 858 else 823 859 print ' Example: -[spec["name"]]:[spec["example"]]' 860 if spec.containsKey('eg') #Verbatim example line 861 print ' e.g. [spec["eg"]]' 824 862 825 863 def doAbout 826 864 # CC: multiline string