Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
98e4008b
Commit
98e4008b
authored
Mar 18, 2014
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't display hint command in options help
Fixes gh-471
parent
2929d33e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
3 deletions
+24
-3
SpringCli.java
...src/main/java/org/springframework/boot/cli/SpringCli.java
+1
-0
CommandRunner.java
...a/org/springframework/boot/cli/command/CommandRunner.java
+23
-3
No files found.
spring-boot-cli/src/main/java/org/springframework/boot/cli/SpringCli.java
View file @
98e4008b
...
...
@@ -44,6 +44,7 @@ public class SpringCli {
runner
.
addCommand
(
new
ShellCommand
());
runner
.
addCommand
(
new
HintCommand
(
runner
));
runner
.
setOptionCommands
(
HelpCommand
.
class
,
VersionCommand
.
class
);
runner
.
setHiddenCommands
(
HintCommand
.
class
);
int
exitCode
=
runner
.
runAndHandleErrors
(
args
);
if
(
exitCode
!=
0
)
{
...
...
spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandRunner.java
View file @
98e4008b
...
...
@@ -46,6 +46,8 @@ public class CommandRunner implements Iterable<Command> {
private
Class
<?>[]
optionCommandClasses
=
{};
private
Class
<?>[]
hiddenCommandClasses
=
{};
/**
* Create a new {@link CommandRunner} instance.
* @param name the name of the runner or {@code null}
...
...
@@ -94,6 +96,16 @@ public class CommandRunner implements Iterable<Command> {
this
.
optionCommandClasses
=
commandClasses
;
}
/**
* Set the command classes which should be hidden (i.e. executed but not displayed in
* the available commands list).
* @param commandClasses the classes of hidden commands
*/
public
void
setHiddenCommands
(
Class
<?>...
commandClasses
)
{
Assert
.
notNull
(
commandClasses
,
"CommandClasses must not be null"
);
this
.
hiddenCommandClasses
=
commandClasses
;
}
/**
* Returns if the specified command is an option command.
* @param command the command to test
...
...
@@ -101,8 +113,16 @@ public class CommandRunner implements Iterable<Command> {
* @see #setOptionCommands(Class...)
*/
public
boolean
isOptionCommand
(
Command
command
)
{
for
(
Class
<?>
optionCommandClass
:
this
.
optionCommandClasses
)
{
if
(
optionCommandClass
.
isInstance
(
command
))
{
return
isCommandInstanceOf
(
command
,
this
.
optionCommandClasses
);
}
private
boolean
isHiddenCommand
(
Command
command
)
{
return
isCommandInstanceOf
(
command
,
this
.
hiddenCommandClasses
);
}
private
boolean
isCommandInstanceOf
(
Command
command
,
Class
<?>[]
commandClasses
)
{
for
(
Class
<?>
commandClass
:
commandClasses
)
{
if
(
commandClass
.
isInstance
(
command
))
{
return
true
;
}
}
...
...
@@ -249,7 +269,7 @@ public class CommandRunner implements Iterable<Command> {
Log
.
info
(
""
);
Log
.
info
(
"Available commands are:"
);
for
(
Command
command
:
this
.
commands
)
{
if
(!
isOptionCommand
(
command
))
{
if
(!
isOptionCommand
(
command
)
&&
!
isHiddenCommand
(
command
)
)
{
String
usageHelp
=
command
.
getUsageHelp
();
String
description
=
command
.
getDescription
();
Log
.
info
(
String
.
format
(
"\n %1$s %2$-15s\n %3$s"
,
command
.
getName
(),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment