I am trying to create a spring boot CLI App using picocli. I followed the steps as mentioned in the tutorial, but when I start the service the whole flow runs. What I want is to call the command from the terminal then only the flow should trigger.Can anyone please help me resolving this. Below is my code.
Component class
public class AppCLI implements CommandLineRunner {
@Autowired
AppCLI appCLI;
public String hello(){
return "hello";
}
@CommandLine.Command(name = "command")
public void command() {
System.out.println("Adding some files to the staging area");
}
@Override
public void run(String... args) throws Exception {
CommandLine commandLine = new CommandLine(appCLI);
commandLine.parseWithHandler(new CommandLine.RunLast(), args);
System.out.println("In the main method");
hello();
command();
}
}
Command class
@Controller
@CommandLine.Command(name = "xyz",description = "Performs ", mixinStandardHelpOptions = true, version = "1.0")
public class AppCLI implements Runnable{
@Override
public void run() {
System.out.println("Hello");
}
}
Main Class
@SpringBootApplication
public class Application {
private static Logger LOG = LoggerFactory.getLogger(Application.class);
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Thanks in advance.