import com.example.cli.CLI; public class MyApp { public static void main(String[] args) { CLI cli = new CLI(); cli.registerCommand("hello", new HelloCommand()); cli.registerCommand("bye", new ByeCommand()); cli.parseAndExecute(args); } } import com.example.cli.Command; public class HelloCommand implements Command { @Override public void execute(String[] args) { System.out.println("Hello, World!"); } } public class ByeCommand implements Command { @Override public void execute(String[] args) { System.out.println("Goodbye!"); } }


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