11package com .mycmd ;
22
3- import lombok .Getter ;
4- import lombok .Setter ;
5- import lombok .NonNull ;
6- import lombok .AccessLevel ;
73import java .io .*;
84import java .time .Instant ;
95import java .util .*;
6+ import lombok .AccessLevel ;
7+ import lombok .Getter ;
8+ import lombok .NonNull ;
9+ import lombok .Setter ;
1010
11- @ Getter (AccessLevel .PUBLIC )
11+ @ Getter (AccessLevel .PUBLIC )
1212public class ShellContext {
13-
14- @ Setter
15- @ NonNull
16- private File currentDir ;
13+
14+ @ Setter @ NonNull private File currentDir ;
1715 private List <String > history ;
1816 private Map <String , String > aliases ;
19-
17+
2018 private static final String ALIAS_FILE = ".mycmd_aliases" ;
2119 private static final int MAX_HISTORY = 100 ;
22-
20+
2321 private final List <String > commandHistory ;
24- private final Instant startTime ;
22+ private final Instant startTime ;
2523
2624 private final Map <String , String > envVars = new HashMap <>();
2725
@@ -34,16 +32,14 @@ public ShellContext() {
3432 loadAliases ();
3533 }
3634
37-
3835 public void addToHistory (String command ) {
3936 history .add (command );
40- commandHistory .add (command );
37+ commandHistory .add (command );
4138 if (history .size () > MAX_HISTORY ) {
4239 history .remove (0 );
4340 }
4441 }
4542
46-
4743 /** RETAINED FOR SAFETY: Returns a DEFENSIVE COPY instead of the raw Map. */
4844 public List <String > getHistory () {
4945 return new ArrayList <>(history );
@@ -52,12 +48,11 @@ public List<String> getHistory() {
5248 public Map <String , String > getAliases () {
5349 return new HashMap <>(aliases );
5450 }
55-
51+
5652 public Map <String , String > getEnvVars () {
5753 return new HashMap <>(envVars );
5854 }
5955
60-
6156 public void clearHistory () {
6257 history .clear ();
6358 }
@@ -71,7 +66,7 @@ public void removeAlias(String name) {
7166 aliases .remove (name );
7267 saveAliases ();
7368 }
74-
69+
7570 public String getAlias (String name ) {
7671 return aliases .get (name );
7772 }
0 commit comments