Skip to content

Commit b412593

Browse files
Merge pull request #15 from nihaltp/feat/whoami
Add WhoamiCommand to display the current user's name
2 parents 6d78465 + 242aed6 commit b412593

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ private static void registerCommands(Map<String, Command> commands) {
5151
commands.put("help", new HelpCommand(commands));
5252
commands.put("exit", new ExitCommand());
5353
commands.put("ver", new VersionCommand());
54+
commands.put("whoami", new WhoamiCommand());
5455
commands.put("touch", new TouchCommand());
5556
commands.put("time", new TimeCommand());
5657
commands.put("date", new DateCommand());
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.mycmd.commands;
2+
3+
import com.mycmd.Command;
4+
import com.mycmd.ShellContext;
5+
6+
public class WhoamiCommand implements Command {
7+
@Override
8+
public void execute(String[] args, ShellContext context) {
9+
System.out.println(System.getProperty("user.name"));
10+
}
11+
}

0 commit comments

Comments
 (0)