You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
670 B
30 lines
670 B
package com.crawler.command;
|
|
|
|
import java.util.List;
|
|
|
|
public class HelpCommand extends BaseCommand {
|
|
private List<Command> commands;
|
|
|
|
public HelpCommand(List<Command> commands) {
|
|
this.commands = commands;
|
|
}
|
|
|
|
@Override
|
|
public String getName() {
|
|
return "help";
|
|
}
|
|
|
|
@Override
|
|
public String getDescription() {
|
|
return "显示所有可用指令";
|
|
}
|
|
|
|
@Override
|
|
public void execute() {
|
|
System.out.println("可用指令:");
|
|
System.out.println("---------");
|
|
for (Command cmd : commands) {
|
|
System.out.printf("%-8s : %s%n", cmd.getName(), cmd.getDescription());
|
|
}
|
|
}
|
|
}
|