Cmd
| 36 | * Cmd |
| 37 | */ |
| 38 | public final class Cmd { |
| 39 | |
| 40 | private final static Command List_f = (List<String> args) -> { |
| 41 | |
| 42 | for (cmd_function_t cmd : Cmd.cmd_functions.values()) { |
| 43 | Com.Printf(cmd.name + '\n'); |
| 44 | } |
| 45 | |
| 46 | Com.Printf(Cmd.cmd_functions.size() + " commands\n"); |
| 47 | }; |
| 48 | |
| 49 | private final static Command Exec_f = (List<String> args) -> { |
| 50 | if (args.size() != 2) { |
| 51 | Com.Printf("exec <filename> : execute a script file\n"); |
| 52 | return; |
| 53 | } |
| 54 | |
| 55 | byte[] f = FS.LoadFile(args.get(1)); |
| 56 | if (f == null) { |
| 57 | Com.Printf("couldn't exec " + args.get(1) + "\n"); |
| 58 | return; |
| 59 | } |
| 60 | Com.Printf("execing " + args.get(1) + "\n"); |
| 61 | Cbuf.InsertText(new String(f)); |
| 62 | |
| 63 | }; |
| 64 | |
| 65 | private final static Command Echo_f = (List<String> args) -> { |
| 66 | if (args.size() < 2) { |
| 67 | Com.Printf("usage: echo expression"); |
| 68 | return; |
| 69 | } |
| 70 | for (int i = 1; i < args.size(); i++) { |
| 71 | Com.Printf(args.get(i) + " "); |
| 72 | } |
| 73 | Com.Printf("'\n"); |
| 74 | }; |
| 75 | |
| 76 | private final static Command Alias_f = (List<String> args) -> { |
| 77 | if (args.size() == 1) { |
| 78 | Com.Printf("Current alias commands:\n"); |
| 79 | for (cmdalias_t alias : Cmd.cmd_alias.values()) { |
| 80 | Com.Printf(alias.getName() + " : " + alias.getValue() + "\n"); |
| 81 | } |
| 82 | return; |
| 83 | } |
| 84 | |
| 85 | // assume args.size >= 2 |
| 86 | String aliasName = args.get(1).trim(); |
| 87 | |
| 88 | if (aliasName.length() > Defines.MAX_ALIAS_NAME) { |
| 89 | Com.Printf("Alias name is too long\n"); |
| 90 | return; |
| 91 | } |
| 92 | |
| 93 | // if the alias already exists, reuse it |
| 94 | cmdalias_t alias = Cmd.cmd_alias.get(aliasName); |
| 95 |
nothing calls this directly
no test coverage detected