11package com .mycmd ;
22
3+ import lombok .Getter ;
4+ import lombok .Setter ;
35import java .io .*;
46import java .util .*;
57import java .time .Instant ;
68
9+ @ Getter
10+ @ Setter
711public class ShellContext {
812 private File currentDir ;
913 private List <String > history ;
@@ -13,6 +17,8 @@ public class ShellContext {
1317 private final List <String > commandHistory ;
1418 private final Instant startTime ;
1519
20+ private final Map <String , String > envVars = new HashMap <>();
21+
1622 public ShellContext () {
1723 this .currentDir = new File (System .getProperty ("user.dir" ));
1824 this .history = new ArrayList <>();
@@ -22,14 +28,6 @@ public ShellContext() {
2228 loadAliases ();
2329 }
2430
25- public File getCurrentDir () {
26- return currentDir ;
27- }
28-
29- public void setCurrentDir (File dir ) {
30- this .currentDir = dir ;
31- }
32-
3331 public void addToHistory (String command ) {
3432 history .add (command );
3533 commandHistory .add (command ); // Add to command history
@@ -38,17 +36,6 @@ public void addToHistory(String command) {
3836 }
3937 }
4038
41- public List <String > getHistory () {
42- return new ArrayList <>(history );
43- }
44-
45- public List <String > getCommandHistory () {
46- return commandHistory ;
47- }
48-
49- public Instant getStartTime () {
50- return startTime ;
51- }
5239
5340 public void clearHistory () {
5441 history .clear ();
@@ -65,14 +52,6 @@ public void removeAlias(String name) {
6552 saveAliases ();
6653 }
6754
68- public String getAlias (String name ) {
69- return aliases .get (name );
70- }
71-
72- public Map <String , String > getAliases () {
73- return new HashMap <>(aliases );
74- }
75-
7655 public boolean hasAlias (String name ) {
7756 return aliases .containsKey (name );
7857 }
@@ -131,21 +110,4 @@ public File resolvePath(String path) {
131110 }
132111 }
133112
134- // environmental variable map
135- // author: Kaveesha Fernando
136- // date: 2024-06-10
137- private final Map <String , String > envVars = new HashMap <>();
138-
139- public void setEnvVar (String key , String value ) {
140- envVars .put (key , value );
141- }
142-
143- public String getEnvVar (String key ) {
144- return envVars .get (key );
145- }
146-
147- public Map <String , String > getEnvVars () {
148- return new HashMap <>(envVars );
149- }
150-
151113}
0 commit comments