Skip to content

Commit 37e359f

Browse files
committed
feat: Add descriptions and usage instructions for command classes
1 parent 16c762d commit 37e359f

15 files changed

+152
-0
lines changed

src/main/java/com/mycmd/commands/CdCommand.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,14 @@ public void execute(String[] args, ShellContext context) {
5353
System.out.println("The system cannot find the path specified.");
5454
}
5555
}
56+
57+
@Override
58+
public String description() {
59+
return "Change the current working directory or display it.";
60+
}
61+
62+
@Override
63+
public String usage() {
64+
return "cd [path]";
65+
}
5666
}

src/main/java/com/mycmd/commands/ClsCommand.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,14 @@ public void execute(String[] args, ShellContext context) {
3434
System.out.println("Error while clearing the screen: " + e.getMessage());
3535
}
3636
}
37+
38+
@Override
39+
public String description() {
40+
return "Clear the console screen.";
41+
}
42+
43+
@Override
44+
public String usage() {
45+
return "cls";
46+
}
3747
}

src/main/java/com/mycmd/commands/ColorCommand.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,17 @@ public void execute(String[] args, ShellContext context) {
6767
System.out.println("\033[0m");
6868
}
6969
}
70+
71+
@Override
72+
public String description() {
73+
return "Change console text and background colors.";
74+
}
75+
76+
@Override
77+
public String usage() {
78+
return "color [<background><text>]\n" +
79+
" <background> and <text> are hexadecimal digits (0-9, A-F).\n" +
80+
" Example: color 0A sets black background with bright green text.\n" +
81+
" Call without arguments to reset to default colors.";
82+
}
7083
}

src/main/java/com/mycmd/commands/CopyCommand.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,14 @@ public void execute(String[] args, ShellContext context) {
4343
System.out.println("Error copying file: " + e.getMessage());
4444
}
4545
}
46+
47+
@Override
48+
public String description() {
49+
return "Copy a file from source to destination.";
50+
}
51+
52+
@Override
53+
public String usage() {
54+
return "copy <source> <destination>";
55+
}
4656
}

src/main/java/com/mycmd/commands/DelCommand.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,14 @@ public void execute(String[] args, ShellContext context) {
3535
}
3636
}
3737
}
38+
39+
@Override
40+
public String description() {
41+
return "Delete one or more files.";
42+
}
43+
44+
@Override
45+
public String usage() {
46+
return "del <file1> [file2 ...]";
47+
}
3848
}

src/main/java/com/mycmd/commands/HistoryCommand.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,14 @@ public void execute(String[] args, ShellContext context) {
2020
System.out.println((i + 1) + ". " + history.get(i));
2121
}
2222
}
23+
24+
@Override
25+
public String description() {
26+
return "Display the list of previously executed commands.";
27+
}
28+
29+
@Override
30+
public String usage() {
31+
return "history";
32+
}
2333
}

src/main/java/com/mycmd/commands/HostnameCommand.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,14 @@ public void execute(String[] args, ShellContext context) {
3131
}
3232
System.out.println(hostname);
3333
}
34+
35+
@Override
36+
public String description() {
37+
return "Display the hostname of the current computer.";
38+
}
39+
40+
@Override
41+
public String usage() {
42+
return "hostname";
43+
}
3444
}

src/main/java/com/mycmd/commands/MkdirCommand.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,14 @@ public void execute(String[] args, ShellContext context) {
3232
System.out.println("Failed to create directory.");
3333
}
3434
}
35+
36+
@Override
37+
public String description() {
38+
return "Create a new directory.";
39+
}
40+
41+
@Override
42+
public String usage() {
43+
return "mkdir <directory_name>";
44+
}
3545
}

src/main/java/com/mycmd/commands/RmdirCommand.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,14 @@ public void execute(String[] args, ShellContext context) {
3737
System.out.println("Failed to delete directory.");
3838
}
3939
}
40+
41+
@Override
42+
public String description() {
43+
return "Remove an empty directory.";
44+
}
45+
46+
@Override
47+
public String usage() {
48+
return "rmdir <directory_name>";
49+
}
4050
}

src/main/java/com/mycmd/commands/TimeCommand.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,14 @@ public void execute(String[] args, ShellContext context) {
3232
String formattedTime = now.format(formatter);
3333
System.out.println("The current time is: " + formattedTime);
3434
}
35+
36+
@Override
37+
public String description() {
38+
return "Display the current local time.";
39+
}
40+
41+
@Override
42+
public String usage() {
43+
return "time";
44+
}
3545
}

0 commit comments

Comments
 (0)