| 40 | import org.openqa.selenium.grid.server.HelpFlags; |
| 41 | |
| 42 | @AutoService(CliCommand.class) |
| 43 | public class InfoCommand implements CliCommand { |
| 44 | |
| 45 | private static final Pattern CODE_OR_LIST_PATTERN = Pattern.compile("^\\s*(\\*|\\d+\\.).*"); |
| 46 | |
| 47 | public String getName() { |
| 48 | return "info"; |
| 49 | } |
| 50 | |
| 51 | public String getDescription() { |
| 52 | return "Prints information for commands and topics."; |
| 53 | } |
| 54 | |
| 55 | @Override |
| 56 | public Set<Role> getConfigurableRoles() { |
| 57 | return Collections.singleton(Role.of("info")); |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public Set<Object> getFlagObjects() { |
| 62 | return Collections.emptySet(); |
| 63 | } |
| 64 | |
| 65 | public Executable configure(PrintStream out, PrintStream err, String... args) { |
| 66 | HelpFlags help = new HelpFlags(); |
| 67 | InfoFlags topic = new InfoFlags(); |
| 68 | |
| 69 | JCommander commander = |
| 70 | JCommander.newBuilder().programName("selenium").addObject(help).addObject(topic).build(); |
| 71 | commander.setConsole(new DefaultConsole(out)); |
| 72 | |
| 73 | return () -> { |
| 74 | try { |
| 75 | commander.parse(args); |
| 76 | } catch (ParameterException e) { |
| 77 | err.println(e.getMessage()); |
| 78 | commander.usage(); |
| 79 | return; |
| 80 | } |
| 81 | |
| 82 | if (help.displayHelp(commander, out)) { |
| 83 | return; |
| 84 | } |
| 85 | |
| 86 | String toDisplay; |
| 87 | String title; |
| 88 | switch (topic.topic) { |
| 89 | case "config": |
| 90 | title = "Configuring Selenium"; |
| 91 | toDisplay = "config.txt"; |
| 92 | break; |
| 93 | |
| 94 | case "security": |
| 95 | title = "About Security"; |
| 96 | toDisplay = "security.txt"; |
| 97 | break; |
| 98 | |
| 99 | case "tracing": |
nothing calls this directly
no outgoing calls
no test coverage detected