Skip to content

Commit e08ace1

Browse files
authored
Merge branch 'main' into feat/color
2 parents f16e5cc + 1431ed6 commit e08ace1

File tree

7 files changed

+117
-30
lines changed

7 files changed

+117
-30
lines changed

CheckList.md

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
## 🧭 System Information & Management
1010
- [ ] systeminfo
1111
- [ ] hostname
12-
- [ ] ver
12+
- [x] ver
1313
- [ ] vol
1414
- [ ] set
1515
- [ ] setx
@@ -27,19 +27,19 @@
2727
---
2828

2929
## 📁 File & Directory Operations
30-
- [ ] dir
31-
- [ ] cd / chdir
32-
- [ ] md / mkdir
33-
- [ ] rd / rmdir
34-
- [ ] del / erase
35-
- [ ] copy
30+
- [x] dir
31+
- [x] cd / chdir
32+
- [x] md / mkdir
33+
- [x] rd / rmdir
34+
- [x] del / erase
35+
- [x] copy
3636
- [ ] xcopy
3737
- [ ] robocopy
38-
- [ ] move
38+
- [x] move
3939
- [ ] rename / ren
4040
- [ ] attrib
4141
- [ ] tree
42-
- [ ] type
42+
- [x] type
4343
- [ ] more
4444
- [ ] find
4545
- [ ] findstr
@@ -52,7 +52,7 @@
5252
---
5353

5454
## 🌐 Network & Internet Commands
55-
- [ ] ping
55+
- [x] ping
5656
- [ ] ipconfig
5757
- [ ] getmac
5858
- [ ] nslookup
@@ -107,14 +107,14 @@
107107
---
108108

109109
## ⚙️ Automation & Scripting
110-
- [ ] echo
110+
- [x] echo
111111
- [ ] pause
112-
- [ ] cls
113-
- [ ] exit
112+
- [x] cls
113+
- [x] exit
114114
- [ ] title
115115
- [ ] color
116116
- [ ] time
117-
- [ ] date
117+
- [x] date
118118
- [ ] shutdown
119119
- [ ] choice
120120
- [ ] timeout
@@ -152,15 +152,15 @@
152152
---
153153

154154
## 🧩 Miscellaneous & Helpers
155-
- [ ] help
155+
- [x] help
156156
- [ ] /? (help flag for any command)
157157
- [ ] doskey
158158
- [ ] mode
159159
- [ ] print
160160
- [ ] subst
161161
- [ ] clip
162162
- [ ] msg
163-
- [ ] ver
163+
- [x] ver
164164
- [ ] verify
165165
- [ ] vol
166166

@@ -170,28 +170,30 @@
170170
- [ ] assoc
171171
- [ ] break
172172
- [ ] call
173-
- [ ] cd / chdir
174-
- [ ] cls
173+
- [x] cd / chdir
174+
- [x] cls
175175
- [ ] color
176-
- [ ] copy
177-
- [ ] date
178-
- [ ] del / erase
179-
- [ ] dir
180-
- [ ] echo
176+
- [x] copy
177+
- [x] date
178+
- [x] del / erase
179+
- [x] dir
180+
- [x] echo
181+
- [x] ls
181182
- [ ] endlocal
182-
- [ ] exit
183+
- [x] exit
183184
- [ ] for
184185
- [ ] ftype
185186
- [ ] goto
186187
- [ ] if
187-
- [ ] md / mkdir
188-
- [ ] move
188+
- [x] md / mkdir
189+
- [x] move
189190
- [ ] path
190191
- [ ] pause
191192
- [ ] popd
192193
- [ ] prompt
193-
- [ ] pushd
194-
- [ ] rd / rmdir
194+
- [ ] pushd
195+
- [x] ping
196+
- [x] rd / rmdir
195197
- [ ] rem
196198
- [ ] ren / rename
197199
- [ ] set
@@ -200,8 +202,8 @@
200202
- [ ] start
201203
- [ ] time
202204
- [ ] title
203-
- [ ] type
204-
- [ ] ver
205+
- [x] type
206+
- [x] ver
205207
- [ ] verify
206208
- [ ] vol
207209

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
<p align="center"><a name="readme-top"></a>
2+
<img src="https://capsule-render.vercel.app/api?type=waving&color=gradient&text=💻+Java+CMD&height=100&section=header"/>
3+
4+
</p>
5+
16
# 💻 MyCMD – A Custom Command Prompt in Java
27

38
![Build](https://img.shields.io/badge/build-passing-brightgreen)
@@ -143,3 +148,5 @@ You can now use commands like:
143148
Licensed under the Apache License
144149
You are free to use, modify, and distribute.
145150

151+
152+
<img src="https://capsule-render.vercel.app/api?type=waving&color=gradient&customColorList=6,11,20&height=120&section=footer&text=Java,%20Java,%20and%20My%20Java&fontSize=20&fontColor=fff&animation=twinkling"/>

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ private static void registerCommands(Map<String, Command> commands) {
5151
commands.put("help", new HelpCommand(commands));
5252
commands.put("exit", new ExitCommand());
5353
commands.put("ver", new VersionCommand());
54+
commands.put("title", new TitleCommand());
5455
commands.put("color", new ColorCommand());
56+
commands.put("hostname", new HostnameCommand());
57+
commands.put("whoami", new WhoamiCommand());
58+
commands.put("touch", new TouchCommand());
59+
commands.put("time", new TimeCommand());
5560
commands.put("date", new DateCommand());
5661
}
5762
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.mycmd.commands;
2+
3+
import java.net.InetAddress;
4+
5+
import com.mycmd.Command;
6+
import com.mycmd.ShellContext;
7+
8+
public class HostnameCommand implements Command {
9+
@Override
10+
public void execute(String[] args, ShellContext context) {
11+
String hostname = System.getenv("COMPUTERNAME");
12+
if (hostname == null) {
13+
try {
14+
hostname = InetAddress.getLocalHost().getHostName();
15+
} catch (Exception e) {
16+
hostname = "Unknown Host";
17+
}
18+
}
19+
System.out.println(hostname);
20+
}
21+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.mycmd.commands;
2+
3+
import com.mycmd.Command;
4+
import com.mycmd.ShellContext;
5+
import java.time.LocalTime;
6+
import java.time.format.DateTimeFormatter;
7+
8+
public class TimeCommand implements Command {
9+
@Override
10+
public void execute(String[] args, ShellContext context) {
11+
LocalTime now = LocalTime.now();
12+
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("H.mm.ss.SS");
13+
String formattedTime = now.format(formatter);
14+
System.out.println("The current time is: " + formattedTime);
15+
}
16+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.mycmd.commands;
2+
3+
import com.mycmd.Command;
4+
import com.mycmd.ShellContext;
5+
import java.io.File;
6+
import java.io.IOException;
7+
8+
public class TouchCommand implements Command {
9+
@Override
10+
public void execute(String[] args, ShellContext context) throws IOException {
11+
if (args.length < 1) { // ✅ Check for at least 1 argument
12+
System.out.println("Usage: touch <filename>");
13+
return;
14+
}
15+
16+
File file = new File(context.getCurrentDir(), args[0]); // ✅ Use args[0]
17+
if (file.createNewFile()) {
18+
System.out.println("File created: " + args[0]); // ✅ Use args[0]
19+
} else {
20+
// Update timestamp
21+
file.setLastModified(System.currentTimeMillis());
22+
System.out.println("File timestamp updated: " + args[0]); // ✅ Use args[0]
23+
}
24+
}
25+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.mycmd.commands;
2+
3+
import com.mycmd.Command;
4+
import com.mycmd.ShellContext;
5+
6+
public class WhoamiCommand implements Command {
7+
@Override
8+
public void execute(String[] args, ShellContext context) {
9+
System.out.println(System.getProperty("user.name"));
10+
}
11+
}

0 commit comments

Comments
 (0)