| 57 | === Command line arguments === |
| 58 | Ruby: |
| 59 | {{{ |
| 60 | #!ruby |
| 61 | ARGV.each {|arg| puts arg} |
| 62 | }}} |
| 63 | Cobra: |
| 64 | {{{ |
| 65 | #!python |
| 66 | class A |
| 67 | def main is shared |
| 68 | for argument in CobraCore.commandLineArgs |
| 69 | print argument |
| 70 | }}} |
| 71 | |
| 72 | Notice that in Cobra, the first argument is the name of the program being called, while in Ruby it's the first parameter. |
| 73 | So, if we were to run the Cobra class above: |
| 74 | |
| 75 | {{{ |
| 76 | cobra.exe a.cobra -run-args one two three |
| 77 | }}} |
| 78 | |
| 79 | You would see the following output: |
| 80 | {{{ |
| 81 | a |
| 82 | one |
| 83 | two |
| 84 | three |
| 85 | }}} |
| 86 | |
| 87 | If you were to run the Ruby script like this: |
| 88 | |
| 89 | {{{ |
| 90 | ruby a.rb one two three |
| 91 | }}} |
| 92 | |
| 93 | You would see this as the output: |
| 94 | |
| 95 | {{{ |
| 96 | one |
| 97 | two |
| 98 | three |
| 99 | }}} |
| 100 | |