Skip to content

Commit

Permalink
Merge Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergix committed Sep 14, 2017
2 parents 3693e44 + 491ec04 commit 4b654b5
Show file tree
Hide file tree
Showing 22 changed files with 327 additions and 146 deletions.
2 changes: 1 addition & 1 deletion init.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@echo off
cls

set JTERM_VERSION=0.5.1
set JTERM_VERSION=0.5.0

prompt dev~JTerm/
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>sergix</groupId>
<artifactId>jterm</artifactId>
<version>0.5.1</version>
<version>0.5.0</version>
<packaging>jar</packaging>
<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>

Expand Down
78 changes: 45 additions & 33 deletions src/main/java/jterm/Dir.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,57 @@ public class Dir
/*
* Dir() void
*
* Constructor for calling methods.
* Constructor for calling Process() function.
*/
public Dir(ArrayList<String> options) { }
public Dir() { }

/*
* Process() void
*
* Process the input.
*
* ArrayList<String> options - command options
* String options - command options
*/
public static void Process(ArrayList<String> options)
public static void Process(String options)
{

// Display help information
System.out.println("Directory Commands\n\nls\tcd\nchdir\tpwd\nmd");
ArrayList<String> optionsArray = JTerm.GetAsArray(options);
if (optionsArray.toArray().length == 0)
optionsArray.add(0, "help");

String command = optionsArray.get(0);
optionsArray.remove(0);

switch (command)
{
case "ls": // @pmorgan3
PrintDir(optionsArray);
break;

case "cd":
case "chdir":
ChangeDir(optionsArray);
break;

case "pwd":
PrintWorkingDir(optionsArray);
break;

case "md":
NewDir(optionsArray);
break;

case "help":
default:
System.out.println("Directory Commands\n\nls\tcd\nchdir\tpwd\nmd\thelp");
return;

}

}

/*
* Ls() void (@pmorgan3)
* PrintDir() void
*
* Prints the contents of a specified directory
* to a file.
Expand All @@ -65,15 +95,13 @@ public static void Process(ArrayList<String> options)
*
* Examples
*
* Ls(options);
* PrintDir(options);
* => [Contents of "dir/"]
* => F RW myFile.txt 2 KB
*/
public static void Ls(ArrayList<String> options) throws NullPointerException
public static void PrintDir(ArrayList<String> options) throws NullPointerException
{

System.out.println(options);

String path = JTerm.currentDirectory;
boolean printFull = true;

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


/*
* Cd() void
* ChangeDir() void
*
* Changes the working directory to the specified
* input.
Expand All @@ -138,7 +166,7 @@ else if (option.equals("-h"))
*
* ArrayList<String> options - command options
*/
public static void Cd(ArrayList<String> options)
public static void ChangeDir(ArrayList<String> options)
{

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


}

/*
* Chdir() void
*
* Identical to 'cd'; calls Cd().
*
* ArrayList<String> options - command options
*/
public static void Chdir(ArrayList<String> options)
{

Cd(options);

}

/*
* Pwd() void
* PrintWorkingDir() void
*
* Prints the working directory to the console.
*
Expand All @@ -222,7 +235,7 @@ public static void Chdir(ArrayList<String> options)
*
* ArrayList<String> options - command options
*/
public static void Pwd(ArrayList<String> options)
public static void PrintWorkingDir(ArrayList<String> options)
{

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

/*
* Md() void
* NewDir() void
*
* Creates a new directory.
*
Expand All @@ -251,7 +264,7 @@ public static void Pwd(ArrayList<String> options)
*
* ArrayList<String> options - command options
*/
public static void Md(ArrayList<String> options)
public static void NewDir(ArrayList<String> options)
{

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

File dir = new File(name);
dir.mkdir();

}

}
32 changes: 29 additions & 3 deletions src/main/java/jterm/Echo.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,35 @@ public class Echo
*
* Constructor for calling Process() function.
*/
public Echo(ArrayList<String> options)
public Echo() { }

/*
* Process() void
*
* Process the input.
*
* String options - command options
*/
public static void Process (String options)
{

EchoInput(JTerm.GetAsArray(options));

}

/*
* EchoInput() void
*
* Echoes the input recieved to the console.
*
* ArrayList<String> options - command options
*
* -h
* Prints help information.
*/
public static void EchoInput(ArrayList<String> options)
{

String output = "";

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

}

output = output.trim();
output = output.substring(0, output.length() - 1);
System.out.println(output);

}

}
12 changes: 6 additions & 6 deletions src/main/java/jterm/Exec.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ public class Exec
*
* Constructor for calling Process() function.
*/
public Exec(ArrayList<String> options) { }
public Exec() { }

/*
* Process() void
*
* Process the input.
*
* ArrayList<String> options - command options
* String options - command options
*/
public static void Process(ArrayList<String> options)
public static void Process(String options)
{
// Default to Run(); nothing to process
Run(options);

ArrayList<String> optionsArray = JTerm.GetAsArray(options);
Run(optionsArray);

}

Expand Down
26 changes: 25 additions & 1 deletion src/main/java/jterm/Exit.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,32 @@ public class Exit
*
* Constructor for calling Process() function.
*/
public Exit(ArrayList<String> options) {
public Exit() { }

/*
* Process() void
*
* Process the input.
*
* String options - command options
*/
public static void Process(String options)
{

ExitApp(JTerm.GetAsArray(options));

}

/*
* ExitApp() void
*
* Exits the application through a system call.
*
* ArrayList<String> options - command options
*/
public static void ExitApp(ArrayList<String> options)
{

System.exit(0);

}
Expand Down
69 changes: 34 additions & 35 deletions src/main/java/jterm/Files.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class Files
*
* Constructor for calling Process() function.
*/
public Files(ArrayList<String> options) { }
public Files() { }

/*
* Process() void
Expand All @@ -40,15 +40,42 @@ public Files(ArrayList<String> options) { }
*
* String options - command options
*/
public static void Process(String options)
public static void Process (String options)
{
ArrayList<String> optionsArray = JTerm.GetAsArray(options);
if (optionsArray.toArray().length == 0)
optionsArray.add(0, "help");

String command = optionsArray.get(0);
optionsArray.remove(0);

switch (command)
{
case "write":
WriteFile(optionsArray);
break;

case "delete":
case "del":
case "rm": // @pmorgan3
Delete(optionsArray);
break;

System.out.println("File Commands\n\nwrite\tdelete\ndel\trm\nread\thelp");
case "read":
ReadFile(optionsArray);
break;

case "help":
default:
System.out.println("File Commands\n\nwrite\tdelete\ndel\trm\nread\thelp");
return;

}

}

/*
* Write() void
* WriteFile() void
*
* Get input and write it to a file.
* Changelog (#65)
Expand All @@ -58,7 +85,7 @@ public static void Process(String options)
* -h
* Prints help information
*/
public static void Write(ArrayList<String> options)
public static void WriteFile(ArrayList<String> options)
{

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

/*
* Rm() void (@pmorgan3)
*
* Identical to 'delete'; calls Delete().
*
* ArrayList<String> options - command options
*/
public static void Rm(ArrayList<String> options)
{

Delete(options);

}

/*
* Del() void (@pmorgan3)
*
* Identical to 'delete'; calls Delete().
*
* ArrayList<String> options - command options
*/
public static void Del(ArrayList<String> options)
{

Delete(options);

}

/*
* Read() void
* ReadFile() void
* Changelog (#68)
*
* Reads the specified files and outputs the contents
Expand All @@ -203,7 +202,7 @@ public static void Del(ArrayList<String> options)
*
* Credit to @d4nntheman
*/
public static void Read(ArrayList<String> options)
public static void ReadFile(ArrayList<String> options)
{

String filename = "";
Expand Down
Loading

0 comments on commit 4b654b5

Please sign in to comment.