Skip to content

Commit 4b654b5

Browse files
committed
Merge Changes
2 parents 3693e44 + 491ec04 commit 4b654b5

22 files changed

+327
-146
lines changed

init.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@echo off
22
cls
33

4-
set JTERM_VERSION=0.5.1
4+
set JTERM_VERSION=0.5.0
55

66
prompt dev~JTerm/

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>sergix</groupId>
77
<artifactId>jterm</artifactId>
8-
<version>0.5.1</version>
8+
<version>0.5.0</version>
99
<packaging>jar</packaging>
1010
<description>JTerm is a cross-platform terminal designed for simple use and to run batch files. JTerm is hosted on GitHub by Sergix and NCSGeek.</description>
1111

src/main/java/jterm/Dir.java

+45-33
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,57 @@ public class Dir
2727
/*
2828
* Dir() void
2929
*
30-
* Constructor for calling methods.
30+
* Constructor for calling Process() function.
3131
*/
32-
public Dir(ArrayList<String> options) { }
32+
public Dir() { }
3333

3434
/*
3535
* Process() void
3636
*
3737
* Process the input.
3838
*
39-
* ArrayList<String> options - command options
39+
* String options - command options
4040
*/
41-
public static void Process(ArrayList<String> options)
41+
public static void Process(String options)
4242
{
4343

44-
// Display help information
45-
System.out.println("Directory Commands\n\nls\tcd\nchdir\tpwd\nmd");
44+
ArrayList<String> optionsArray = JTerm.GetAsArray(options);
45+
if (optionsArray.toArray().length == 0)
46+
optionsArray.add(0, "help");
47+
48+
String command = optionsArray.get(0);
49+
optionsArray.remove(0);
50+
51+
switch (command)
52+
{
53+
case "ls": // @pmorgan3
54+
PrintDir(optionsArray);
55+
break;
56+
57+
case "cd":
58+
case "chdir":
59+
ChangeDir(optionsArray);
60+
break;
61+
62+
case "pwd":
63+
PrintWorkingDir(optionsArray);
64+
break;
65+
66+
case "md":
67+
NewDir(optionsArray);
68+
break;
69+
70+
case "help":
71+
default:
72+
System.out.println("Directory Commands\n\nls\tcd\nchdir\tpwd\nmd\thelp");
73+
return;
74+
75+
}
4676

4777
}
4878

4979
/*
50-
* Ls() void (@pmorgan3)
80+
* PrintDir() void
5181
*
5282
* Prints the contents of a specified directory
5383
* to a file.
@@ -65,15 +95,13 @@ public static void Process(ArrayList<String> options)
6595
*
6696
* Examples
6797
*
68-
* Ls(options);
98+
* PrintDir(options);
6999
* => [Contents of "dir/"]
70100
* => F RW myFile.txt 2 KB
71101
*/
72-
public static void Ls(ArrayList<String> options) throws NullPointerException
102+
public static void PrintDir(ArrayList<String> options) throws NullPointerException
73103
{
74104

75-
System.out.println(options);
76-
77105
String path = JTerm.currentDirectory;
78106
boolean printFull = true;
79107

@@ -126,7 +154,7 @@ else if (option.equals("-h"))
126154

127155

128156
/*
129-
* Cd() void
157+
* ChangeDir() void
130158
*
131159
* Changes the working directory to the specified
132160
* input.
@@ -138,7 +166,7 @@ else if (option.equals("-h"))
138166
*
139167
* ArrayList<String> options - command options
140168
*/
141-
public static void Cd(ArrayList<String> options)
169+
public static void ChangeDir(ArrayList<String> options)
142170
{
143171

144172
String newDirectory = "";
@@ -195,25 +223,10 @@ else if ((!dir.exists() || !dir.isDirectory()) && (!newDir.exists() || !newDir.i
195223
// It does exist, and it is a directory, so just change the global working directory variable to the input
196224
JTerm.currentDirectory = newDirectory;
197225

198-
199-
}
200-
201-
/*
202-
* Chdir() void
203-
*
204-
* Identical to 'cd'; calls Cd().
205-
*
206-
* ArrayList<String> options - command options
207-
*/
208-
public static void Chdir(ArrayList<String> options)
209-
{
210-
211-
Cd(options);
212-
213226
}
214227

215228
/*
216-
* Pwd() void
229+
* PrintWorkingDir() void
217230
*
218231
* Prints the working directory to the console.
219232
*
@@ -222,7 +235,7 @@ public static void Chdir(ArrayList<String> options)
222235
*
223236
* ArrayList<String> options - command options
224237
*/
225-
public static void Pwd(ArrayList<String> options)
238+
public static void PrintWorkingDir(ArrayList<String> options)
226239
{
227240

228241
for (String option: options)
@@ -242,7 +255,7 @@ public static void Pwd(ArrayList<String> options)
242255
}
243256

244257
/*
245-
* Md() void
258+
* NewDir() void
246259
*
247260
* Creates a new directory.
248261
*
@@ -251,7 +264,7 @@ public static void Pwd(ArrayList<String> options)
251264
*
252265
* ArrayList<String> options - command options
253266
*/
254-
public static void Md(ArrayList<String> options)
267+
public static void NewDir(ArrayList<String> options)
255268
{
256269

257270
String name = "";
@@ -274,7 +287,6 @@ public static void Md(ArrayList<String> options)
274287

275288
File dir = new File(name);
276289
dir.mkdir();
277-
278290
}
279291

280292
}

src/main/java/jterm/Echo.java

+29-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,35 @@ public class Echo
2828
*
2929
* Constructor for calling Process() function.
3030
*/
31-
public Echo(ArrayList<String> options)
31+
public Echo() { }
32+
33+
/*
34+
* Process() void
35+
*
36+
* Process the input.
37+
*
38+
* String options - command options
39+
*/
40+
public static void Process (String options)
3241
{
3342

43+
EchoInput(JTerm.GetAsArray(options));
44+
45+
}
46+
47+
/*
48+
* EchoInput() void
49+
*
50+
* Echoes the input recieved to the console.
51+
*
52+
* ArrayList<String> options - command options
53+
*
54+
* -h
55+
* Prints help information.
56+
*/
57+
public static void EchoInput(ArrayList<String> options)
58+
{
59+
3460
String output = "";
3561

3662
for (String option: options)
@@ -46,9 +72,9 @@ public Echo(ArrayList<String> options)
4672

4773
}
4874

49-
output = output.trim();
75+
output = output.substring(0, output.length() - 1);
5076
System.out.println(output);
51-
77+
5278
}
5379

5480
}

src/main/java/jterm/Exec.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@ public class Exec
2828
*
2929
* Constructor for calling Process() function.
3030
*/
31-
public Exec(ArrayList<String> options) { }
31+
public Exec() { }
3232

3333
/*
3434
* Process() void
3535
*
3636
* Process the input.
3737
*
38-
* ArrayList<String> options - command options
38+
* String options - command options
3939
*/
40-
public static void Process(ArrayList<String> options)
40+
public static void Process(String options)
4141
{
42-
43-
// Default to Run(); nothing to process
44-
Run(options);
42+
43+
ArrayList<String> optionsArray = JTerm.GetAsArray(options);
44+
Run(optionsArray);
4545

4646
}
4747

src/main/java/jterm/Exit.java

+25-1
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,32 @@ public class Exit
2828
*
2929
* Constructor for calling Process() function.
3030
*/
31-
public Exit(ArrayList<String> options) {
31+
public Exit() { }
32+
33+
/*
34+
* Process() void
35+
*
36+
* Process the input.
37+
*
38+
* String options - command options
39+
*/
40+
public static void Process(String options)
41+
{
42+
43+
ExitApp(JTerm.GetAsArray(options));
3244

45+
}
46+
47+
/*
48+
* ExitApp() void
49+
*
50+
* Exits the application through a system call.
51+
*
52+
* ArrayList<String> options - command options
53+
*/
54+
public static void ExitApp(ArrayList<String> options)
55+
{
56+
3357
System.exit(0);
3458

3559
}

src/main/java/jterm/Files.java

+34-35
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class Files
3131
*
3232
* Constructor for calling Process() function.
3333
*/
34-
public Files(ArrayList<String> options) { }
34+
public Files() { }
3535

3636
/*
3737
* Process() void
@@ -40,15 +40,42 @@ public Files(ArrayList<String> options) { }
4040
*
4141
* String options - command options
4242
*/
43-
public static void Process(String options)
43+
public static void Process (String options)
4444
{
45+
ArrayList<String> optionsArray = JTerm.GetAsArray(options);
46+
if (optionsArray.toArray().length == 0)
47+
optionsArray.add(0, "help");
48+
49+
String command = optionsArray.get(0);
50+
optionsArray.remove(0);
51+
52+
switch (command)
53+
{
54+
case "write":
55+
WriteFile(optionsArray);
56+
break;
57+
58+
case "delete":
59+
case "del":
60+
case "rm": // @pmorgan3
61+
Delete(optionsArray);
62+
break;
4563

46-
System.out.println("File Commands\n\nwrite\tdelete\ndel\trm\nread\thelp");
64+
case "read":
65+
ReadFile(optionsArray);
66+
break;
67+
68+
case "help":
69+
default:
70+
System.out.println("File Commands\n\nwrite\tdelete\ndel\trm\nread\thelp");
71+
return;
72+
73+
}
4774

4875
}
4976

5077
/*
51-
* Write() void
78+
* WriteFile() void
5279
*
5380
* Get input and write it to a file.
5481
* Changelog (#65)
@@ -58,7 +85,7 @@ public static void Process(String options)
5885
* -h
5986
* Prints help information
6087
*/
61-
public static void Write(ArrayList<String> options)
88+
public static void WriteFile(ArrayList<String> options)
6289
{
6390

6491
String filename = "";
@@ -162,35 +189,7 @@ public static void Delete(ArrayList<String> options)
162189
}
163190

164191
/*
165-
* Rm() void (@pmorgan3)
166-
*
167-
* Identical to 'delete'; calls Delete().
168-
*
169-
* ArrayList<String> options - command options
170-
*/
171-
public static void Rm(ArrayList<String> options)
172-
{
173-
174-
Delete(options);
175-
176-
}
177-
178-
/*
179-
* Del() void (@pmorgan3)
180-
*
181-
* Identical to 'delete'; calls Delete().
182-
*
183-
* ArrayList<String> options - command options
184-
*/
185-
public static void Del(ArrayList<String> options)
186-
{
187-
188-
Delete(options);
189-
190-
}
191-
192-
/*
193-
* Read() void
192+
* ReadFile() void
194193
* Changelog (#68)
195194
*
196195
* Reads the specified files and outputs the contents
@@ -203,7 +202,7 @@ public static void Del(ArrayList<String> options)
203202
*
204203
* Credit to @d4nntheman
205204
*/
206-
public static void Read(ArrayList<String> options)
205+
public static void ReadFile(ArrayList<String> options)
207206
{
208207

209208
String filename = "";

0 commit comments

Comments
 (0)