org.springframework.shell.SimpleShellCommandLineOptions Java Examples
The following examples show how to use
org.springframework.shell.SimpleShellCommandLineOptions.
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: ShellCommandLineParser.java From spring-cloud-dashboard with Apache License 2.0 | 6 votes |
/** * Parse {@link ShellProperties} and {@link ApplicationArguments} to create an instance of the * @param shellProperties the shell properties * @param applicationArguments the raw unprocessed arguments that were passed to the application. * @return a new {@link CommandLine} instance. */ public CommandLine parse(ShellProperties shellProperties, String[] applicationArguments) { List<String> commands = new ArrayList<String>(); if (shellProperties.getCommandFile() != null) { File f = new File(shellProperties.getCommandFile()); try { commands.addAll(FileUtils.readLines(f)); } catch (IOException e) { logger.error("Unable to read from " + f.toString(), e); } } String[] commandsToExecute = (commands.size() > 0) ? commands.toArray(new String[commands.size()]) : null; int historySize = shellProperties.getHistorySize(); if (historySize < 0) { logger.warn("historySize option must be > 0, using default value of " + SimpleShellCommandLineOptions.DEFAULT_HISTORY_SIZE); historySize = SimpleShellCommandLineOptions.DEFAULT_HISTORY_SIZE; } return new CommandLine(applicationArguments, historySize, commandsToExecute); }
Example #2
Source File: ShellCommandLineParser.java From spring-cloud-dataflow with Apache License 2.0 | 6 votes |
/** * Parse {@link ShellProperties} and {@link ApplicationArguments} to create an * instance of the * * @param shellProperties the shell properties * @param applicationArguments the raw unprocessed arguments that were passed to the * application. * @return a new {@link CommandLine} instance. */ public CommandLine parse(ShellProperties shellProperties, String[] applicationArguments) { List<String> commands = new ArrayList<String>(); if (shellProperties.getCommandFile() != null) { for (String filePath : shellProperties.getCommandFile()) { File f = new File(filePath); try { commands.addAll(FileUtils.readLines(f)); } catch (IOException e) { logger.error("Unable to read from " + f.toString(), e); } } } String[] commandsToExecute = (commands.size() > 0) ? commands.toArray(new String[commands.size()]) : null; int historySize = shellProperties.getHistorySize(); if (historySize < 0) { logger.warn("historySize option must be > 0, using default value of " + SimpleShellCommandLineOptions.DEFAULT_HISTORY_SIZE); historySize = SimpleShellCommandLineOptions.DEFAULT_HISTORY_SIZE; } return new CommandLine(applicationArguments, historySize, commandsToExecute); }
Example #3
Source File: BootShim.java From spring-data-dev-tools with Apache License 2.0 | 6 votes |
public BootShim(String[] args, ConfigurableApplicationContext context) { this.ctx = context; try { commandLine = SimpleShellCommandLineOptions.parseCommandLine(args); } catch (IOException var5) { throw new ShellException(var5.getMessage(), var5); } this.configureApplicationContext(this.ctx); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner((BeanDefinitionRegistry) this.ctx); if (commandLine.getDisableInternalCommands()) { scanner.scan(new String[] { "org.springframework.shell.converters", "org.springframework.shell.plugin.support" }); } else { scanner.scan(new String[] { "org.springframework.shell.commands", "org.springframework.shell.converters", "org.springframework.shell.plugin.support" }); } }
Example #4
Source File: BootShim.java From hdfs-shell with Apache License 2.0 | 5 votes |
public BootShim(String[] args, ConfigurableApplicationContext context) { this.ctx = context; try { commandLine = SimpleShellCommandLineOptions.parseCommandLine(args); } catch (IOException var5) { throw new ShellException(var5.getMessage(), var5); } this.configureApplicationContext(this.ctx); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner((BeanDefinitionRegistry) this.ctx); if (commandLine.getDisableInternalCommands()) { scanner.scan("org.springframework.shell.converters", "org.springframework.shell.plugin.support"); } else { scanner.scan("org.springframework.shell.commands", "org.springframework.shell.converters", "org.springframework.shell.plugin.support"); } }
Example #5
Source File: ShellConfiguration.java From ambari-shell with Apache License 2.0 | 4 votes |
@Bean CommandLine commandLine() throws Exception { String[] args = cmdFile.length() > 0 ? new String[]{"--cmdfile", cmdFile} : new String[0]; return SimpleShellCommandLineOptions.parseCommandLine(args); }