org.springframework.shell.jline.InteractiveShellApplicationRunner Java Examples

The following examples show how to use org.springframework.shell.jline.InteractiveShellApplicationRunner. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SshShellAutoConfiguration.java    From ssh-shell-spring-boot with Apache License 2.0 6 votes vote down vote up
/**
 * Primary shell application runner which answers true to {@link InteractiveShellApplicationRunner#isEnabled()}
 *
 * @param lineReader     line reader
 * @param promptProvider prompt provider
 * @param parser         parser
 * @param shell          spring shell
 * @param environment    spring environment
 * @return shell application runner
 */
@Bean
@Primary
public InteractiveShellApplicationRunner sshInteractiveShellApplicationRunner(LineReader lineReader,
                                                                              PromptProvider promptProvider,
                                                                              Parser parser, Shell shell,
                                                                              Environment environment) {
    return new InteractiveShellApplicationRunner(lineReader, promptProvider, parser, shell, environment) {

        @Override
        public boolean isEnabled() {
            return true;
        }

        @Override
        public void run(ApplicationArguments args) {
            // do nothing
        }
    };
}
 
Example #2
Source File: InteractiveModeApplicationRunner.java    From spring-cloud-skipper with Apache License 2.0 6 votes vote down vote up
@Override
public void run(ApplicationArguments args) throws Exception {
	// if we have args, assume one time run
	ArrayList<String> argsToShellCommand = new ArrayList<>();
	for (String arg : args.getSourceArgs()) {
		// consider client connection options as non command args
		if (!arg.contains("spring.cloud.skipper.client")) {
			argsToShellCommand.add(arg);
		}
	}
	if (argsToShellCommand.size() > 0) {
		if (ShellUtils.hasHelpOption(args)) {
			// going into 'help' mode. HelpAwareShellApplicationRunner already
			// printed usage, we just force running just help.
			argsToShellCommand.clear();
			argsToShellCommand.add("help");
		}
	}

	if (!argsToShellCommand.isEmpty()) {
		InteractiveShellApplicationRunner.disable(environment);
		shell.run(new StringInputProvider(argsToShellCommand));
	}
}
 
Example #3
Source File: InteractiveShellLifecycle.java    From Cleanstone with MIT License 5 votes vote down vote up
@Override
public void run() {
    InputProvider inputProvider = new InteractiveShellApplicationRunner.JLineInputProvider(lineReader, promptProvider);
    try {
        shell.run(inputProvider);
    } catch (IOException e) {
        log.error("Error in Shell Subsystem", e);
        CleanstoneServer.stop();
    }
}