Skip to content

Commit a045da7

Browse files
committed
feat(lombok): Use Lombok Annotations to resolve #52
1 parent 16c762d commit a045da7

File tree

2 files changed

+15
-46
lines changed

2 files changed

+15
-46
lines changed

pom.xml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,16 @@
1717
<maven.compiler.target>17</maven.compiler.target>
1818
</properties>
1919

20+
<dependencies>
21+
<dependency>
22+
<groupId>org.projectlombok</groupId>
23+
<artifactId>lombok</artifactId>
24+
<version>1.18.32</version>
25+
<scope>provided</scope>
26+
</dependency>
27+
</dependencies>
2028
<build>
2129
<plugins>
22-
<!-- Creates executable jar -->
2330
<plugin>
2431
<groupId>org.apache.maven.plugins</groupId>
2532
<artifactId>maven-jar-plugin</artifactId>
@@ -34,4 +41,4 @@
3441
</plugin>
3542
</plugins>
3643
</build>
37-
</project>
44+
</project>

src/main/java/com/mycmd/ShellContext.java

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
package com.mycmd;
22

3+
import lombok.Getter;
4+
import lombok.Setter;
35
import java.io.*;
46
import java.util.*;
57
import java.time.Instant;
68

9+
@Getter
10+
@Setter
711
public 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

Comments
 (0)