<dependency> <groupId>org.rogach</groupId> <artifactId>scallop_${scala.binary.version}</artifactId> <version>3.4.1</version> </dependency> implementation 'org.rogach:scallop_${scala.binary.version}:3.4.1' import org.rogach.scallop.{ScallopConf,ScallopOption}; public class CommandLineAppConf extends ScallopConf { val input: ScallopOption[String] = opt[String](required = true, descr = "Input file") val output: ScallopOption[String] = opt[String](required = true, descr = "Output file") val verbose: ScallopOption[Boolean] = toggle("verbose", default = Some(false), noshort = true, descrYes = "Verbose output") verify() } public class CommandLineApp { public static void main(String[] args) { val conf = new CommandLineAppConf(args) val inputFile = conf.input() val outputFile = conf.output() val isVerbose = conf.verbose() // ... } }


上一篇:
下一篇:
切换中文