Skip to content

Commit d79d593

Browse files
Merge pull request #90 from smirk-dev/main
Main
2 parents da25985 + bb6ad41 commit d79d593

78 files changed

Lines changed: 3349 additions & 484 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"java.configuration.updateBuildConfiguration": "interactive"
3+
}

CheckList.md

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@
1010
- [x] systeminfo
1111
- [x] hostname
1212
- [x] ver
13-
- [ ] vol
14-
- [ ] set
13+
- [x] vol
14+
- [x] set
1515
- [ ] setx
16-
- [ ] wmic
17-
- [ ] driverquery
18-
- [ ] tasklist
19-
- [ ] taskkill
20-
- [ ] sfc
21-
- [ ] chkdsk
22-
- [ ] label
23-
- [ ] fsutil
24-
- [ ] assoc
25-
- [ ] ftype
16+
- [x] wmic
17+
- [x] driverquery
18+
- [x] tasklist
19+
- [x] taskkill
20+
- [x] sfc
21+
- [x] chkdsk
22+
- [x] label
23+
- [x] fsutil
24+
- [x] assoc
25+
- [x] ftype
2626

2727
---
2828

@@ -33,46 +33,46 @@
3333
- [x] rd / rmdir
3434
- [x] del / erase
3535
- [x] copy
36-
- [ ] xcopy
37-
- [ ] robocopy
36+
- [x] xcopy
37+
- [x] robocopy
3838
- [x] move
39-
- [ ] rename / ren
40-
- [ ] attrib
39+
- [x] rename / ren
40+
- [x] attrib
4141
- [x] tree
4242
- [x] type
43-
- [ ] more
44-
- [ ] find
45-
- [ ] findstr
46-
- [ ] sort
47-
- [ ] fc
48-
- [ ] forfiles
49-
- [ ] compact
50-
- [ ] replace
43+
- [x] more
44+
- [x] find
45+
- [x] findstr
46+
- [x] sort
47+
- [x] fc
48+
- [x] forfiles
49+
- [x] compact
50+
- [x] replace
5151

5252
---
5353

5454
## 🌐 Network & Internet Commands
5555
- [x] ping
56-
- [ ] ipconfig
57-
- [ ] getmac
58-
- [ ] nslookup
59-
- [ ] netstat
60-
- [ ] tracert
56+
- [x] ipconfig
57+
- [x] getmac
58+
- [x] nslookup
59+
- [x] netstat
60+
- [x] tracert
6161
- [ ] pathping
62-
- [ ] arp
63-
- [ ] route
64-
- [ ] netsh
62+
- [x] arp
63+
- [x] route
64+
- [x] netsh
6565
- [ ] ftp
6666
- [ ] tftp
67-
- [ ] telnet
67+
- [x] telnet
6868
- [ ] nbtstat
69-
- [ ] net
70-
- [ ] net user
71-
- [ ] net use
72-
- [ ] net share
73-
- [ ] net start
74-
- [ ] net stop
75-
- [ ] net session
69+
- [x] net
70+
- [x] net user
71+
- [x] net use
72+
- [x] net share
73+
- [x] net start
74+
- [x] net stop
75+
- [x] net session
7676
- [ ] curl
7777
- [ ] powershell
7878

@@ -119,8 +119,8 @@
119119
- [ ] choice
120120
- [x] timeout
121121
- [ ] call
122-
- [ ] start
123-
- [ ] taskkill
122+
- [x] start
123+
- [x] taskkill
124124
- [ ] schtasks
125125
- [ ] for
126126
- [ ] if
@@ -158,11 +158,11 @@
158158
- [ ] mode
159159
- [ ] print
160160
- [ ] subst
161-
- [ ] clip
162-
- [ ] msg
161+
- [x] clip
162+
- [x] msg
163163
- [x] ver
164-
- [ ] verify
165-
- [ ] vol
164+
- [x] verify
165+
- [x] vol
166166

167167
---
168168

pom.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,21 @@
5656
</archive>
5757
</configuration>
5858
</plugin>
59+
60+
<!-- Spotless code formatter -->
61+
<plugin>
62+
<groupId>com.diffplug.spotless</groupId>
63+
<artifactId>spotless-maven-plugin</artifactId>
64+
<version>2.43.0</version>
65+
<configuration>
66+
<java>
67+
<googleJavaFormat>
68+
<version>1.17.0</version>
69+
<style>AOSP</style>
70+
</googleJavaFormat>
71+
</java>
72+
</configuration>
73+
</plugin>
5974
</plugins>
6075
</build>
6176
</project>

src/main/java/com/mycmd/App.java

Lines changed: 89 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.mycmd;
22

33
import com.mycmd.commands.*;
4-
import com.mycmd.utils.StringUtils;
5-
64
import java.util.*;
75
import java.util.Scanner;
86

@@ -42,7 +40,12 @@ public static void main(String[] args) {
4240
}
4341
} else {
4442
// 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.");
4649

4750
// compute suggestion safely
4851
try {
@@ -75,78 +78,157 @@ private static String resolveAliases(String input, ShellContext context) {
7578

7679
private static final class CommandNames {
7780
private CommandNames() {}
81+
7882
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";
7986
private static final String CD = "cd";
87+
private static final String CHKDSK = "chkdsk";
88+
private static final String CHOICE = "choice";
8089
private static final String CLEARHISTORY = "clearhistory";
90+
private static final String CLIP = "clip";
8191
private static final String CLS = "cls";
8292
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";
8495
private static final String DATE = "date";
8596
private static final String DEL = "del";
8697
private static final String DIR = "dir";
98+
private static final String DRIVERQUERY = "driverquery";
8799
private static final String ECHO = "echo";
88100
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";
89108
private static final String HELP = "help";
90109
private static final String HISTORY = "history";
91110
private static final String HOSTNAME = "hostname";
92111
private static final String IPCONFIG = "ipconfig";
112+
private static final String LABEL = "label";
113+
private static final String LS = "ls";
93114
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";
95124
private static final String PING = "ping";
96125
private static final String PWD = "pwd";
126+
private static final String REM = "rem";
97127
private static final String RENAME = "rename";
128+
private static final String REPLACE = "replace";
98129
private static final String RMDIR = "rmdir";
130+
private static final String ROBOCOPY = "robocopy";
131+
private static final String ROUTE = "route";
99132
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";
100137
private static final String SYSTEMINFO = "systeminfo";
138+
private static final String TASKKILL = "taskkill";
101139
private static final String TASKLIST = "tasklist";
102140
private static final String TELNET = "telnet";
103141
private static final String TIME = "time";
104142
private static final String TIMEOUT = "timeout";
105143
private static final String TITLE = "title";
106144
private static final String TOUCH = "touch";
145+
private static final String TRACERT = "tracert";
107146
private static final String TREE = "tree";
108147
private static final String TYPE = "type";
109148
private static final String UNALIAS = "unalias";
110149
private static final String UPTIME = "uptime";
111150
private static final String VER = "ver";
151+
private static final String VERIFY = "verify";
152+
private static final String VOL = "vol";
112153
private static final String WHOAMI = "whoami";
154+
private static final String WMIC = "wmic";
155+
private static final String XCOPY = "xcopy";
113156
}
114-
157+
115158
private static void registerCommands(Map<String, Command> commands) {
116159
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());
117163
commands.put(CommandNames.CD, new CdCommand());
164+
commands.put(CommandNames.CHKDSK, new ChkdskCommand());
165+
commands.put(CommandNames.CHOICE, new ChoiceCommand());
118166
commands.put(CommandNames.CLEARHISTORY, new ClearHistoryCommand());
167+
commands.put(CommandNames.CLIP, new ClipCommand());
119168
commands.put(CommandNames.CLS, new ClsCommand());
120169
commands.put(CommandNames.COLOR, new ColorCommand());
170+
commands.put(CommandNames.COMPACT, new CompactCommand());
121171
commands.put(CommandNames.COPY, new CopyCommand());
122172
commands.put(CommandNames.DATE, new DateCommand());
123173
commands.put(CommandNames.DEL, new DelCommand());
124174
commands.put(CommandNames.DIR, new DirCommand());
175+
commands.put(CommandNames.DRIVERQUERY, new DriverqueryCommand());
125176
commands.put(CommandNames.ECHO, new EchoCommand());
126177
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());
127185
commands.put(CommandNames.HELP, new HelpCommand(commands));
128186
commands.put(CommandNames.HISTORY, new HistoryCommand());
129187
commands.put(CommandNames.HOSTNAME, new HostnameCommand());
130188
commands.put(CommandNames.IPCONFIG, new IpConfig());
189+
commands.put(CommandNames.LABEL, new LabelCommand());
190+
commands.put(CommandNames.LS, new LsCommand());
131191
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());
132200
commands.put(CommandNames.PAUSE, new PauseCommand());
133201
commands.put(CommandNames.PING, new PingCommand());
134202
commands.put(CommandNames.PWD, new PwdCommand());
203+
commands.put(CommandNames.REM, new RemCommand());
135204
commands.put(CommandNames.RENAME, new RenameCommand());
205+
commands.put(CommandNames.REPLACE, new ReplaceCommand());
136206
commands.put(CommandNames.RMDIR, new RmdirCommand());
207+
commands.put(CommandNames.ROBOCOPY, new RobocopyCommand());
208+
commands.put(CommandNames.ROUTE, new RouteCommand());
137209
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());
139216
commands.put(CommandNames.TASKLIST, new TasklistCommand());
140217
commands.put(CommandNames.TELNET, new TelnetCommand());
141218
commands.put(CommandNames.TIME, new TimeCommand());
142219
commands.put(CommandNames.TIMEOUT, new TimeoutCommand());
143220
commands.put(CommandNames.TITLE, new TitleCommand());
144221
commands.put(CommandNames.TOUCH, new TouchCommand());
222+
commands.put(CommandNames.TRACERT, new TracertCommand());
145223
commands.put(CommandNames.TREE, new TreeCommand());
146224
commands.put(CommandNames.TYPE, new TypeCommand());
147225
commands.put(CommandNames.UNALIAS, new UnaliasCommand());
148226
commands.put(CommandNames.UPTIME, new UptimeCommand());
149227
commands.put(CommandNames.VER, new VersionCommand());
228+
commands.put(CommandNames.VERIFY, new VerifyCommand());
229+
commands.put(CommandNames.VOL, new VolCommand());
150230
commands.put(CommandNames.WHOAMI, new WhoamiCommand());
231+
commands.put(CommandNames.WMIC, new WmicCommand());
232+
commands.put(CommandNames.XCOPY, new XcopyCommand());
151233
}
152234
}

src/main/java/com/mycmd/Command.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
import java.io.IOException;
44

55
/**
6-
* Represents a shell command that can be executed inside the MyCMD shell.
7-
* Implementations perform their operation when {@link #execute(String[], ShellContext)} is called.
6+
* Represents a shell command that can be executed inside the MyCMD shell. Implementations perform
7+
* their operation when {@link #execute(String[], ShellContext)} is called.
88
*/
99
public interface Command {
1010
/**
1111
* Execute the command.
1212
*
13-
* @param args command-line style arguments passed to the command. May be empty but will not be null.
13+
* @param args command-line style arguments passed to the command. May be empty but will not be
14+
* null.
1415
* @param context current shell context containing state such as the current working directory.
1516
* @throws IOException if the command cannot complete successfully.
1617
*/
@@ -23,10 +24,8 @@ default String description() {
2324
return "";
2425
}
2526

26-
/**
27-
* Usage string for the command. Default is empty.
28-
*/
27+
/** Usage string for the command. Default is empty. */
2928
default String usage() {
3029
return "";
3130
}
32-
}
31+
}

0 commit comments

Comments
 (0)