|
1 | 1 | package com.mycmd; |
2 | 2 |
|
3 | 3 | import com.mycmd.commands.*; |
4 | | -import com.mycmd.utils.StringUtils; |
5 | | - |
6 | 4 | import java.util.*; |
7 | 5 | import java.util.Scanner; |
8 | 6 |
|
@@ -42,7 +40,12 @@ public static void main(String[] args) { |
42 | 40 | } |
43 | 41 | } else { |
44 | 42 | // Single, clear not-recognized message + optional suggestion |
45 | | - System.out.println("Unknown command: '" + cmd + "'. Enter '" + CommandNames.HELP + "' to list all available commands."); |
| 43 | + System.out.println( |
| 44 | + "Unknown command: '" |
| 45 | + + cmd |
| 46 | + + "'. Enter '" |
| 47 | + + CommandNames.HELP |
| 48 | + + "' to list all available commands."); |
46 | 49 |
|
47 | 50 | // compute suggestion safely |
48 | 51 | try { |
@@ -75,78 +78,157 @@ private static String resolveAliases(String input, ShellContext context) { |
75 | 78 |
|
76 | 79 | private static final class CommandNames { |
77 | 80 | private CommandNames() {} |
| 81 | + |
78 | 82 | private static final String ALIAS = "alias"; |
| 83 | + private static final String ARP = "arp"; |
| 84 | + private static final String ASSOC = "assoc"; |
| 85 | + private static final String ATTRIB = "attrib"; |
79 | 86 | private static final String CD = "cd"; |
| 87 | + private static final String CHKDSK = "chkdsk"; |
| 88 | + private static final String CHOICE = "choice"; |
80 | 89 | private static final String CLEARHISTORY = "clearhistory"; |
| 90 | + private static final String CLIP = "clip"; |
81 | 91 | private static final String CLS = "cls"; |
82 | 92 | private static final String COLOR = "color"; |
83 | | - private static final String COPY = "copy"; |
| 93 | + private static final String COMPACT = "compact"; |
| 94 | + private static final String COPY = "copy"; |
84 | 95 | private static final String DATE = "date"; |
85 | 96 | private static final String DEL = "del"; |
86 | 97 | private static final String DIR = "dir"; |
| 98 | + private static final String DRIVERQUERY = "driverquery"; |
87 | 99 | private static final String ECHO = "echo"; |
88 | 100 | private static final String EXIT = "exit"; |
| 101 | + private static final String FC = "fc"; |
| 102 | + private static final String FIND = "find"; |
| 103 | + private static final String FINDSTR = "findstr"; |
| 104 | + private static final String FORFILES = "forfiles"; |
| 105 | + private static final String FSUTIL = "fsutil"; |
| 106 | + private static final String FTYPE = "ftype"; |
| 107 | + private static final String GETMAC = "getmac"; |
89 | 108 | private static final String HELP = "help"; |
90 | 109 | private static final String HISTORY = "history"; |
91 | 110 | private static final String HOSTNAME = "hostname"; |
92 | 111 | private static final String IPCONFIG = "ipconfig"; |
| 112 | + private static final String LABEL = "label"; |
| 113 | + private static final String LS = "ls"; |
93 | 114 | private static final String MKDIR = "mkdir"; |
94 | | - private static final String PAUSE = "pause"; |
| 115 | + private static final String MORE = "more"; |
| 116 | + private static final String MOVE = "move"; |
| 117 | + private static final String MSG = "msg"; |
| 118 | + private static final String NET = "net"; |
| 119 | + private static final String NETSH = "netsh"; |
| 120 | + private static final String NETSTAT = "netstat"; |
| 121 | + private static final String NSLOOKUP = "nslookup"; |
| 122 | + private static final String PATH = "path"; |
| 123 | + private static final String PAUSE = "pause"; |
95 | 124 | private static final String PING = "ping"; |
96 | 125 | private static final String PWD = "pwd"; |
| 126 | + private static final String REM = "rem"; |
97 | 127 | private static final String RENAME = "rename"; |
| 128 | + private static final String REPLACE = "replace"; |
98 | 129 | private static final String RMDIR = "rmdir"; |
| 130 | + private static final String ROBOCOPY = "robocopy"; |
| 131 | + private static final String ROUTE = "route"; |
99 | 132 | private static final String SET = "set"; |
| 133 | + private static final String SFC = "sfc"; |
| 134 | + private static final String SHUTDOWN = "shutdown"; |
| 135 | + private static final String SORT = "sort"; |
| 136 | + private static final String START = "start"; |
100 | 137 | private static final String SYSTEMINFO = "systeminfo"; |
| 138 | + private static final String TASKKILL = "taskkill"; |
101 | 139 | private static final String TASKLIST = "tasklist"; |
102 | 140 | private static final String TELNET = "telnet"; |
103 | 141 | private static final String TIME = "time"; |
104 | 142 | private static final String TIMEOUT = "timeout"; |
105 | 143 | private static final String TITLE = "title"; |
106 | 144 | private static final String TOUCH = "touch"; |
| 145 | + private static final String TRACERT = "tracert"; |
107 | 146 | private static final String TREE = "tree"; |
108 | 147 | private static final String TYPE = "type"; |
109 | 148 | private static final String UNALIAS = "unalias"; |
110 | 149 | private static final String UPTIME = "uptime"; |
111 | 150 | private static final String VER = "ver"; |
| 151 | + private static final String VERIFY = "verify"; |
| 152 | + private static final String VOL = "vol"; |
112 | 153 | private static final String WHOAMI = "whoami"; |
| 154 | + private static final String WMIC = "wmic"; |
| 155 | + private static final String XCOPY = "xcopy"; |
113 | 156 | } |
114 | | - |
| 157 | + |
115 | 158 | private static void registerCommands(Map<String, Command> commands) { |
116 | 159 | commands.put(CommandNames.ALIAS, new AliasCommand()); |
| 160 | + commands.put(CommandNames.ARP, new ArpCommand()); |
| 161 | + commands.put(CommandNames.ASSOC, new AssocCommand()); |
| 162 | + commands.put(CommandNames.ATTRIB, new AttribCommand()); |
117 | 163 | commands.put(CommandNames.CD, new CdCommand()); |
| 164 | + commands.put(CommandNames.CHKDSK, new ChkdskCommand()); |
| 165 | + commands.put(CommandNames.CHOICE, new ChoiceCommand()); |
118 | 166 | commands.put(CommandNames.CLEARHISTORY, new ClearHistoryCommand()); |
| 167 | + commands.put(CommandNames.CLIP, new ClipCommand()); |
119 | 168 | commands.put(CommandNames.CLS, new ClsCommand()); |
120 | 169 | commands.put(CommandNames.COLOR, new ColorCommand()); |
| 170 | + commands.put(CommandNames.COMPACT, new CompactCommand()); |
121 | 171 | commands.put(CommandNames.COPY, new CopyCommand()); |
122 | 172 | commands.put(CommandNames.DATE, new DateCommand()); |
123 | 173 | commands.put(CommandNames.DEL, new DelCommand()); |
124 | 174 | commands.put(CommandNames.DIR, new DirCommand()); |
| 175 | + commands.put(CommandNames.DRIVERQUERY, new DriverqueryCommand()); |
125 | 176 | commands.put(CommandNames.ECHO, new EchoCommand()); |
126 | 177 | commands.put(CommandNames.EXIT, new ExitCommand()); |
| 178 | + commands.put(CommandNames.FC, new FcCommand()); |
| 179 | + commands.put(CommandNames.FIND, new FindCommand()); |
| 180 | + commands.put(CommandNames.FINDSTR, new FindstrCommand()); |
| 181 | + commands.put(CommandNames.FORFILES, new ForfilesCommand()); |
| 182 | + commands.put(CommandNames.FSUTIL, new FsutilCommand()); |
| 183 | + commands.put(CommandNames.FTYPE, new FtypeCommand()); |
| 184 | + commands.put(CommandNames.GETMAC, new GetmacCommand()); |
127 | 185 | commands.put(CommandNames.HELP, new HelpCommand(commands)); |
128 | 186 | commands.put(CommandNames.HISTORY, new HistoryCommand()); |
129 | 187 | commands.put(CommandNames.HOSTNAME, new HostnameCommand()); |
130 | 188 | commands.put(CommandNames.IPCONFIG, new IpConfig()); |
| 189 | + commands.put(CommandNames.LABEL, new LabelCommand()); |
| 190 | + commands.put(CommandNames.LS, new LsCommand()); |
131 | 191 | commands.put(CommandNames.MKDIR, new MkdirCommand()); |
| 192 | + commands.put(CommandNames.MORE, new MoreCommand()); |
| 193 | + commands.put(CommandNames.MOVE, new MoveCommand()); |
| 194 | + commands.put(CommandNames.MSG, new MsgCommand()); |
| 195 | + commands.put(CommandNames.NET, new NetCommand()); |
| 196 | + commands.put(CommandNames.NETSH, new NetshCommand()); |
| 197 | + commands.put(CommandNames.NETSTAT, new NetstatCommand()); |
| 198 | + commands.put(CommandNames.NSLOOKUP, new NslookupCommand()); |
| 199 | + commands.put(CommandNames.PATH, new PathCommand()); |
132 | 200 | commands.put(CommandNames.PAUSE, new PauseCommand()); |
133 | 201 | commands.put(CommandNames.PING, new PingCommand()); |
134 | 202 | commands.put(CommandNames.PWD, new PwdCommand()); |
| 203 | + commands.put(CommandNames.REM, new RemCommand()); |
135 | 204 | commands.put(CommandNames.RENAME, new RenameCommand()); |
| 205 | + commands.put(CommandNames.REPLACE, new ReplaceCommand()); |
136 | 206 | commands.put(CommandNames.RMDIR, new RmdirCommand()); |
| 207 | + commands.put(CommandNames.ROBOCOPY, new RobocopyCommand()); |
| 208 | + commands.put(CommandNames.ROUTE, new RouteCommand()); |
137 | 209 | commands.put(CommandNames.SET, new SetCommand()); |
138 | | - commands.put(CommandNames.SYSTEMINFO, new SysteminfoCommand()); |
| 210 | + commands.put(CommandNames.SFC, new SfcCommand()); |
| 211 | + commands.put(CommandNames.SHUTDOWN, new ShutdownCommand()); |
| 212 | + commands.put(CommandNames.SORT, new SortCommand()); |
| 213 | + commands.put(CommandNames.START, new StartCommand()); |
| 214 | + commands.put(CommandNames.SYSTEMINFO, new SysteminfoCommand()); |
| 215 | + commands.put(CommandNames.TASKKILL, new TaskkillCommand()); |
139 | 216 | commands.put(CommandNames.TASKLIST, new TasklistCommand()); |
140 | 217 | commands.put(CommandNames.TELNET, new TelnetCommand()); |
141 | 218 | commands.put(CommandNames.TIME, new TimeCommand()); |
142 | 219 | commands.put(CommandNames.TIMEOUT, new TimeoutCommand()); |
143 | 220 | commands.put(CommandNames.TITLE, new TitleCommand()); |
144 | 221 | commands.put(CommandNames.TOUCH, new TouchCommand()); |
| 222 | + commands.put(CommandNames.TRACERT, new TracertCommand()); |
145 | 223 | commands.put(CommandNames.TREE, new TreeCommand()); |
146 | 224 | commands.put(CommandNames.TYPE, new TypeCommand()); |
147 | 225 | commands.put(CommandNames.UNALIAS, new UnaliasCommand()); |
148 | 226 | commands.put(CommandNames.UPTIME, new UptimeCommand()); |
149 | 227 | commands.put(CommandNames.VER, new VersionCommand()); |
| 228 | + commands.put(CommandNames.VERIFY, new VerifyCommand()); |
| 229 | + commands.put(CommandNames.VOL, new VolCommand()); |
150 | 230 | commands.put(CommandNames.WHOAMI, new WhoamiCommand()); |
| 231 | + commands.put(CommandNames.WMIC, new WmicCommand()); |
| 232 | + commands.put(CommandNames.XCOPY, new XcopyCommand()); |
151 | 233 | } |
152 | 234 | } |
0 commit comments