forked from Drive-for-Java/MyCMD
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPwdCommand.java
More file actions
35 lines (31 loc) · 993 Bytes
/
Copy pathPwdCommand.java
File metadata and controls
35 lines (31 loc) · 993 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;
/**
* Prints the current working directory.
*
* This command displays the absolute path of the current working directory
* stored in the shell context. It's equivalent to the Unix/Linux 'pwd' command
* and provides the same functionality as 'cd' without arguments.
*
* Usage:
* - pwd : Print the current working directory path
*
* The command always prints the absolute path of the current directory,
* making it useful for scripts and when you need to know your exact location
* in the file system.
*/
public class PwdCommand implements Command {
@Override
public void execute(String[] args, ShellContext context) {
System.out.println(context.getCurrentDir().getAbsolutePath());
}
@Override
public String description() {
return "Print the current working directory path.";
}
@Override
public String usage() {
return "pwd";
}
}