-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Spring Boot 2.0 #4
Comments
I didn't test yet. Could you please share with me any issues you get with Spring boot 2 |
Hi Thibaud, i have a strange behaviour where i try to inject a @service annotated class into (sub) command. @Component
@Command(name = "module", description="create module")
public class CmdModule extends HelpAwarePicocliCommand {
private static final Logger logger = Logger.getLogger(CmdModule.class.getName());
@Autowired
private FileSystemService fss;
private FileSystem fileSystem;
@Option(names={ "-i", "--init" }, description="init new module in current directory")
private boolean initModule;
@Option(names={ "-d", "--disable" }, description="disable module and all commands")
private boolean disableModule;
@Option(names={ "-e", "--enable" }, description="enable module and all commands")
private boolean enableModule;
@Parameters(index="0", paramLabel="<module-name>", description="human readable module name")
private String moduleName;
@PostConstruct
private void postConstruct() {
requireNonNull(fss, "filesystem service not injected");
fileSystem = fss.getFileSystem();
}
/* (non-Javadoc)
* @see java.util.concurrent.Callable#call()
*/
@Override
public ExitStatus call() throws Exception {
logger.info("user.dir: " + System.getProperty("user.dir")); // does it!
// Path root = fileSystem.getPath("/");
// DirectoryStream<Path> subdirs = Files.newDirectoryStream(root);
fileSystem.getRootDirectories().forEach(dir -> logger.info("subdir: " + dir.toAbsolutePath().toString()));
if (!(initModule ^ disableModule ^ enableModule) ^ (initModule && disableModule && enableModule)) {
// throw new Exception (String.format("only one option of [%s, %s, %s] is possible", "-i", "-d", "-e"));
throw new Exception ("only one option is possible");
}
if (initModule) {
initModule(moduleName);
}
if (disableModule) {
disableModule(moduleName);
}
if (enableModule) {
enableModule(moduleName);
}
return ExitStatus.TERMINATION;
}
/**
* @param name
*/
private void enableModule(String name) {
System.out.println(String.format("enable module «%s»", name));
}
/**
* @param name
*/
private void disableModule(String name) {
System.out.println(String.format("disable module «%s»", name));
}
private void initModule(String name) {
System.out.println(String.format("init new module «%s»", name));
Path path = Paths.get("");
String s = path.toAbsolutePath().toString();
// System.out.println("current path = " + s);
}
} in postconstruct any ideas? |
@rome-legacy Ok I think I understand your issue, I'll checkout asap |
Hi @kakawait, i've tried to downgrade the libs to spring boot 1 and have the same problem. am i doing something wrong? |
@rome-legacy will be fixed on next version |
This would be great for folks on the newest versions of Spring Boot.
The text was updated successfully, but these errors were encountered: