package com.example.module1; import scalop.Arguments; public class Module1 { public static void main(String[] args) { } } package com.example.module1; import scalop.Arguments; import scalop.Inject; import scalop.Injector; public class Module1 { @Inject private Dependency dependency; public Module1() { Injector.inject(this); } public void doSomething() { dependency.doSomething(); } } class Dependency { public void doSomething() { } } package com.example.module1; import scalop.Arguments; import scalop.Option; public class Module1 { @Option(names = {"-v", "--verbose"}, description = "Enable verbose mode") private boolean verbose; public static void main(String[] args) { Module1 module = new Module1(); Arguments.parse(args, module); if (module.verbose) { } } } package com.example.module1; import scalop.Arguments; import scalop.Command; import scalop.Option; public class Module1 { @Command(name = "subcommand1", description = "First subcommand") static class Subcommand1 { @Option(names = {"-v", "--verbose"}, description = "Enable verbose mode") private boolean verbose; public void run() { if (verbose) { } } } @Command(name = "subcommand2", description = "Second subcommand") static class Subcommand2 { // ... } public static void main(String[] args) { Arguments.parse(args, new Subcommand1(), new Subcommand2()); } }


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