Skip to content

Commit 2b80892

Browse files
Merge pull request #85 from nihaltp/feature/pause
[FEATURE] pause
2 parents d9ef9fa + 38c7f45 commit 2b80892

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

CheckList.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108

109109
## ⚙️ Automation & Scripting
110110
- [x] echo
111-
- [ ] pause
111+
- [x] pause
112112
- [x] cls
113113
- [x] exit
114114
- [x] title
@@ -188,7 +188,7 @@
188188
- [x] md / mkdir
189189
- [x] move
190190
- [ ] path
191-
- [ ] pause
191+
- [x] pause
192192
- [ ] popd
193193
- [ ] prompt
194194
- [ ] pushd

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,6 @@ private static void registerCommands(Map<String, Command> commands) {
107107
commands.put("rename", new RenameCommand());
108108
commands.put("set", new SetCommand());
109109
commands.put("systeminfo", new SysteminfoCommand());
110+
commands.put("pause", new PauseCommand());
110111
}
111112
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.mycmd.commands;
2+
3+
import com.mycmd.Command;
4+
import com.mycmd.ShellContext;
5+
6+
public class PauseCommand implements Command {
7+
/**
8+
* Execute the pause command.
9+
*
10+
* <p>Prints "Press Enter to continue..." and waits for the user to press Enter before continuing.</p>
11+
* <p>If an exception occurs during the pause, it is ignored.</p>
12+
*
13+
* @param args The arguments to the command.
14+
* @param context The context of the shell.
15+
*/
16+
@Override
17+
public void execute(String[] args, ShellContext context) {
18+
System.out.println("Press Enter to continue...");
19+
try {
20+
System.in.read();
21+
} catch (Exception e) {
22+
// Ignore exceptions during pause
23+
}
24+
}
25+
26+
@Override
27+
public String description() {
28+
return "Pause execution until user presses Enter.";
29+
}
30+
31+
@Override
32+
public String usage() {
33+
return "pause";
34+
}
35+
}

0 commit comments

Comments
 (0)