forked from Drive-for-Java/MyCMD
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPauseCommand.java
More file actions
35 lines (31 loc) · 937 Bytes
/
Copy pathPauseCommand.java
File metadata and controls
35 lines (31 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.mycmd.commands;
import com.mycmd.Command;
import com.mycmd.ShellContext;
public class PauseCommand implements Command {
/**
* Execute the pause command.
*
* <p>Prints "Press Enter to continue..." and waits for the user to press Enter before continuing.</p>
* <p>If an exception occurs during the pause, it is ignored.</p>
*
* @param args The arguments to the command.
* @param context The context of the shell.
*/
@Override
public void execute(String[] args, ShellContext context) {
System.out.println("Press Enter to continue...");
try {
System.in.read();
} catch (Exception e) {
// Ignore exceptions during pause
}
}
@Override
public String description() {
return "Pause execution until user presses Enter.";
}
@Override
public String usage() {
return "pause";
}
}