forked from Drive-for-Java/MyCMD
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWhoamiCommand.java
More file actions
33 lines (29 loc) · 872 Bytes
/
Copy pathWhoamiCommand.java
File metadata and controls
33 lines (29 loc) · 872 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
package com.mycmd.commands;
import com.mycmd.Command;
import com.mycmd.ShellContext;
/**
* Displays the username of the current user.
*
* This command retrieves and displays the system username from the Java
* system property "user.name". This typically corresponds to the login
* name of the user running the application.
*
* Usage: whoami
*
* Note: This command does not accept any arguments and always displays
* the current user's name as reported by the Java runtime.
*/
public class WhoamiCommand implements Command {
@Override
public void execute(String[] args, ShellContext context) {
System.out.println(System.getProperty("user.name"));
}
@Override
public String description() {
return "Display the username of logged in user";
}
@Override
public String usage() {
return "whoami";
}
}