I am trying in a groovy script to use picocli to get an interactive password prompt and get the error @picocli.CommandLine$Option is not allowed on element LOCAL_VARIABLE. I am using Groovy 4.0.5 and Picocli 4.6.3. Below is my code.
import static picocli.CommandLine.*
import groovy.transform.Field
import java.security.MessageDigest
@Command(name = 'checksum', mixinStandardHelpOptions = true, version = 'checksum 4.0',
description = 'Prints the checksum (SHA-256 by default) of a file to STDOUT.')
@picocli.groovy.PicocliScript
@Parameters(index = '0', description = 'The file whose checksum to calculate.')
@Field File file
@Option(names = ['-a', '--algorithm'], description = 'MD5, SHA-1, SHA-256, ...')
@Field String algorithm = 'SHA-256'
@Option(names = [ '-p','--password'], description = "Passphrase", interactive = true)
char[] password;
println MessageDigest.getInstance(algorithm).digest(file.bytes).encodeHex().toString()
At the commandline I tried
groovy PicocliTest.groovy findClassPath.groovy -p