Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-9886

Groovy 3: cli builder not honoring type correctly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None

    Description

      The following code runs in groovy 2 but not groovy 3

      def cli = new CliBuilder(writer : new PrintWriter(System.out))
      def opt = 'a'
      def key = 'abc'
      def type = double.class
      def desc = 'abc'
      cli."$opt"(args: 1, longOpt: key, type: type, desc)
      def options = cli.parse(['--abc', '0.00'])
      options.getOptions().each {
          assert(it.getType().toString() == 'double')
      }
      

      groovy 3 output

      
      Assertion failed: 
      
      assert(it.getType().toString() == 'double')
             |  |         |          |
             |  |         |          false
             |  |         'class java.lang.String'
             |  class java.lang.String
             [ option: a abc  [ARG] :: abc :: class java.lang.String ]
      
      	at ConsoleScript26$_run_closure1.doCall(ConsoleScript26:9)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at ConsoleScript26.run(ConsoleScript26:8)
      	at jdk.internal.reflect.GeneratedMethodAccessor61.invoke(Unknown Source)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            howardzzhang Howard
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 2h 10m
                2h 10m