Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SHL-66 - Plugins should have access to command line options
- Loading branch information
1 parent
bab23f2
commit 730e33d
Showing
8 changed files
with
203 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright 2011-2012 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.shell; | ||
|
||
|
||
/** | ||
* Encapsulates the list of argument passed to the shell. | ||
* | ||
* @author Mark Pollack | ||
*/ | ||
public class CommandLine { | ||
|
||
private String[] args; | ||
private int historySize; | ||
private String[] shellCommandsToExecute; | ||
|
||
/** | ||
* Construct a new CommandLine | ||
* @param args an array of strings from main(String[] args) | ||
* @param historySize the size of this history buffer | ||
* @param shellCommandsToExecute semi-colon delimited list of commands for the shell to execute | ||
*/ | ||
public CommandLine(String[] args, int historySize, String[] shellCommandsToExecute) { | ||
this.args = args; | ||
this.historySize = historySize; | ||
this.shellCommandsToExecute = shellCommandsToExecute; | ||
} | ||
|
||
/** | ||
* Return the command line arguments | ||
* @return the command line arguments | ||
*/ | ||
public String[] getArgs() { | ||
return args; | ||
} | ||
|
||
/** | ||
* @return the historySize | ||
*/ | ||
public int getHistorySize() { | ||
return historySize; | ||
} | ||
|
||
/** | ||
* @return the shellCommandsToExecute | ||
*/ | ||
public String[] getShellCommandsToExecute() { | ||
return shellCommandsToExecute; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/test/java/org/springframework/shell/commands/test/OptionsInjectedDummyCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.springframework.shell.commands.test; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.shell.CommandLine; | ||
import org.springframework.shell.core.CommandMarker; | ||
import org.springframework.shell.core.annotation.CliCommand; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class OptionsInjectedDummyCommand implements CommandMarker { | ||
|
||
@Autowired | ||
private CommandLine commandLine; | ||
|
||
@CliCommand("do nothing") | ||
public String simple() { | ||
return "foo"; | ||
} | ||
|
||
public CommandLine getCommandLine() { | ||
return commandLine; | ||
} | ||
|
||
} |
Oops, something went wrong.