Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions CheckList.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

## 🧭 System Information & Management
- [ ] systeminfo
- [ ] hostname
- [x] hostname
- [x] ver
- [ ] vol
- [ ] set
Expand Down Expand Up @@ -38,7 +38,7 @@
- [x] move
- [ ] rename / ren
- [ ] attrib
- [ ] tree
- [x] tree
- [x] type
- [ ] more
- [ ] find
Expand Down Expand Up @@ -97,7 +97,7 @@
- [ ] net user
- [ ] net localgroup
- [ ] runas
- [ ] whoami
- [x] whoami
- [ ] cacls
- [ ] icacls
- [ ] cipher
Expand All @@ -111,9 +111,9 @@
- [ ] pause
- [x] cls
- [x] exit
- [ ] title
- [ ] color
- [ ] time
- [x] title
- [x] color
- [x] time
- [x] date
- [ ] shutdown
- [ ] choice
Expand Down Expand Up @@ -172,7 +172,7 @@
- [ ] call
- [x] cd / chdir
- [x] cls
- [ ] color
- [x] color
- [x] copy
- [x] date
- [x] del / erase
Expand Down Expand Up @@ -200,8 +200,8 @@
- [ ] setlocal
- [ ] shift
- [ ] start
- [ ] time
- [ ] title
- [x] time
- [x] title
- [x] type
- [x] ver
- [ ] verify
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/mycmd/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ private static void registerCommands(Map<String, Command> commands) {
commands.put("whoami", new WhoamiCommand());
commands.put("touch", new TouchCommand());
commands.put("time", new TimeCommand());
commands.put("tree", new TreeCommand());
commands.put("date", new DateCommand());
}
}
37 changes: 37 additions & 0 deletions src/main/java/com/mycmd/commands/TreeCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.mycmd.commands;

import com.mycmd.Command;
import com.mycmd.ShellContext;
import java.io.File;

public class TreeCommand implements Command {
public void execute(String[] args, ShellContext context) {
File[] files = context.getCurrentDir().listFiles();

if (files == null || files.length == 0) {
System.out.println("No files found.");
return;
}

System.out.println(context.getCurrentDir().getAbsolutePath());
printDirectory(files, "", true);
System.out.println();
}

private void printDirectory(File[] files, String prefix, boolean isLast) {
if (files == null || files.length == 0) return;

for (int i = 0; i < files.length; i++) {
File f = files[i];
if (f.isHidden()) continue;

boolean last = (i == files.length - 1);
System.out.println(prefix + (last ? "└───" : "├───") + f.getName());

if (f.isDirectory()) {
String newPrefix = prefix + (last ? " " : "│ ");
printDirectory(f.listFiles(), newPrefix, last);
}
}
}
}