title: Pass command-line arguments to Groovy script
body: <p>I have a simple Groovy script like this:</p>
  
  <pre><code>class Main {
      static void main(String... args) {
          args.each {
              println ${it}
          }
      }
  }
  </code></pre>
  
  <p>I cannot figure out how to pass command line arguments to it. I'm on Windows and run the script as:</p>
  
  <blockquote>
    <p>Groovy myscript.groovy "arg1" "arg2"</p>
  </blockquote>
  
  <p>And it results in error:</p>
  
  <blockquote>
    <p>Caught: groovy.lang.MissingMethodException: No signature of method: Main$_main_closure1.$() is applicable for argument types: (Main$_main_closure1$_closure2) values: [Main$_main_closure1$_closure2@68b32e3e]
    Possible solutions: is(java.lang.Object), is(java.lang.Object), any(), any(), any(groovy.lang.Closure), use([Ljava.lang.Object;)
    groovy.lang.MissingMethodException: No signature of method: Main$_main_closure1.$() is applicable for argument types: (Main$_main_closure1$_closure2) values: [Main$_main_closure1$_closure2@68b32e3e]
    Possible solutions: is(java.lang.Object), is(java.lang.Object), any(), any(), any(groovy.lang.Closure), use([Ljava.lang.Object;)
            at Main$_main_closure1.doCall(hash_text.groovy:10)
            at Main.main(hash_text.groovy:9)</p>
  </blockquote>