Skip to content

Commit

Permalink
Merge pull request #5 from Sergix/dev
Browse files Browse the repository at this point in the history
Release v0.3.0
  • Loading branch information
NCSGeek authored Jun 8, 2017
2 parents 2daeaec + 3642d0a commit 2030b8b
Show file tree
Hide file tree
Showing 12 changed files with 655 additions and 44 deletions.
26 changes: 26 additions & 0 deletions build/changelog/jterm-changelog-v0.3.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Changelog entry:

[6/4/2017-20:08 0.3.0 Sergix]
Release 0.3.0 has been pushed with the associated documentation and other data.
Documentation now includes a section covering commands that JTerm provides.
The Client/Server classes are included in the packaged source, although they are not actually used in the release executable; see associated release documentation for more details.
Pushed updates to Git.

Full changes include:
- Created "Client" class
- Added "connect" command; called with `Client.Connect()` function
- NOT FUNCTIONING in this release; source is included
- Created "Server" class
- Added "server" command; called with `Server.Start()` function
- NOT FUNCTIONING in this release; source is included
- Created "Window" class
- Added "window" command; called with `new Window()` function
- Added the "md" command (Make Directory) that calls the new `Dir.NewDir()` function
- Added the "del" command (DELete) that calls the new `Files.Delete()` function
- In-development source code is now pushed to the `dev` branch on the repository, which will be merged with `master` on release
- Inputed commands convert to all lowercase
- `Write` class has been removed; member function moved to `Files` class
- The current directory will always end with a single "forward slash" (e.g. `/usr/home/`)
- Other minor fixes

More information provided in published release documentation.
Binary file added build/jar/jterm-v0.3.0.jar
Binary file not shown.
Binary file added build/src/jterm-src-v0.3.0.zip
Binary file not shown.
1 change: 0 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
- Added command option parsing for WriteFile
- Made inputed commands (not options) default to lowercase
- Files.Delete deletes both files AND directories
-
Created "dev" branch that will be used for development.
Fixed incorrect date in last changelog entry.

Expand Down
81 changes: 81 additions & 0 deletions docs/release/jterm-v0.3.0-docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# JTerm Documentation v0.3.0

## Table of Contents
```
I. Table of Contents
II. Overview
III. Build Targets
IV. Changelog
V. New Features
A. Commands
B. Client/Server
VI. Active Command List
```

## Overview
This document provides information on changes included in release version "0.3.0". The JTerm project is still far from its official release, but the project has had enough changes to include it as a new pre-release version. This document was written by @Sergix and reviewed by @NCSGeek.

## Build Targets
```
[VERSION] [FILE] [STATE]
0.1.0 jterm-v0.1.0.jar OK
0.2.0 jterm-v0.2.0.jar OK
0.2.1 jterm-v0.2.1.jar OK
0.3.0 jterm-v0.3.0.jar OK
```

## Changelog
- Created "Client" class
- Added "connect" command; called with `Client.Connect()` function
- NOT FUNCTIONING in this release; source is included
- Created "Server" class
- Added "server" command; called with `Server.Start()` function
- NOT FUNCTIONING in this release; source is included
- Created "Window" class
- Added "window" command; called with `new Window()` function
- Added the "md" command (Make Directory) that calls the new `Dir.NewDir()` function
- Added the "del" command (DELete) that calls the new `Files.Delete()` function
- In-development source code is now pushed to the `dev` branch on the repository, which will be merged with `master` on release
- Inputed commands convert to all lowercase
- `Write` class has been removed; member function moved to `Files` class
- The current directory will always end with a single "forward slash" (e.g. `/usr/home/`)
- Other minor fixes

## New Features

### Commands
The commands `connect`, `server`, `md`, `del`, and `window` have been added to JTerm. The syntax for these commands are as follows:
```
connect [-h] [-p port] address
server [-h] port
md [-h] name
del [-h] file/directory
window [-h] [-r] [-w width] [-l height] [-t title]
```
`connect` AND `server` ARE NOT FUNCTIONABLE IN THIS RELEASE.
`-h` ALWAYS displays the command's help information in the console. `-r`, used for the `window` command, toggles resizability for the created window.

### Client/Server
As mentioned before, a new Client/Server interface has been written for JTerm. However, this functionality has too many issues to be released yet. The source code and classes are packaged into the source build, as well as the JAR, but it is not able to be run. Any presented fixes to the issues are welcome.

## Active Command List
- `help` - displays information about JTerm
- `quit` - Exits the JTerm application
- `write [-h] filename` - Opens an input prompt that will write the data to the new file named `filename`
- `dir [-f] [-h] [directory]` - Dispays extensive directory information, including files and subdirectories
- `-f` - toggles minimal output
- `cd [-h] directory` - Changes the directory to the location specified
- `pwd` - prints the current working directory
- `echo [-h] input` - outputs the input on a new line
- `del [-h] file/directory` - deletes the specified file or directory
- `md [-h] name` - creates a new directory
- `window [-h] [-r] [-w width] [-l height] [-t title]` - creates a new GUI window
- `-r` - toggles resizability
- `-w` - specifies window width
- `-l` - specifies window height
- `-t` - sets the name of the window, displayed in the title bar

> JTerm 0.3.0
> `jterm-v0.3.0.jar`
> This project and its source are held under the GNU General Public License, located in the LICENSE file in the project's directory.
> (c) 2017
110 changes: 110 additions & 0 deletions src/main/java/com/jterm/Client.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package main.java.com.jterm;

import java.io.*;
import java.net.Socket;
import java.util.ArrayList;

public class Client implements Runnable {

private static BufferedReader input;

public void run() {

while (true) {
try {
String output = Client.input.readLine();
if (output != null)
System.out.println(output);

} catch (IOException ioe) {
return;

}

}

}

public static void Connect(ArrayList<String> options) {

String address = "0.0.0.0";
String portInput = "80";
boolean next = false;

for (String option: options) {
if (option.equals("-h"))
{
System.out.println("Command syntax:\n\tconnect [-h] [-p port] address\n\nConnect to the specified IP address using TCP/IP. Default address is \"0.0.0.0\". Default port is 80.");
return;

}
else if (option.equals("-p"))
{
next = true;

}
else if (next)
{
portInput = option;
next = false;

}
else
{
address = option;

}

}

int i = 0;
int port = 0;

while( i < portInput.length())
{
port *= 10;
port += portInput.charAt(i++) - '0';

}

try {
System.out.println("Connecting to " + address + ":" + port);

Socket connection = new Socket(address, port);
InputStream input = connection.getInputStream();
OutputStream output = connection.getOutputStream();
BufferedReader bufferedSocketInput = new BufferedReader(new InputStreamReader(input));

Client.input = bufferedSocketInput;

Client client = new Client();
Thread readThread = new Thread(client);
readThread.start();

System.out.println("Connected to server. Enter a blank line to quit. Reading for input...");

while (true) {
BufferedReader bufferedSocketOutput = new BufferedReader(new InputStreamReader(System.in), 1);
String line = bufferedSocketOutput.readLine();

if (line.equals(""))
break;
output.write(line.getBytes());

output.close();
bufferedSocketOutput.close();

}

connection.close();

}
catch (IOException ioe)
{
System.out.println("Connection severed.");

}

}

}
47 changes: 46 additions & 1 deletion src/main/java/com/jterm/Dir.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,25 @@ public static void ChangeDir(ArrayList<String> options) {

// Test if the input exists and if it is a directory
File dir = new File(newDirectory);
if (!dir.exists() || !dir.isDirectory()) {
File newDir = new File(JTerm.currentDirectory + newDirectory);

if (newDir.exists() && newDir.isDirectory()) {
newDirectory = JTerm.currentDirectory + newDirectory;

}
else if ((!dir.exists() || !dir.isDirectory()) && (!newDir.exists() || !newDir.isDirectory()))
{
System.out.println("ERROR: Directory \"" + newDirectory + "\" is either does not exist or is not a valid directory.");
return;

}

if (!newDirectory.endsWith("/"))
{
newDirectory += "/";

}

// It does exist, and it is a directory, so just change the global working directory variable to the input
JTerm.currentDirectory = newDirectory;

Expand Down Expand Up @@ -163,4 +176,36 @@ public static void PrintWorkingDir(ArrayList<String> options) {
System.out.println(JTerm.currentDirectory);

}

/*
* NewDir() void
*
* Creates a new directory.
*
* -h
* Prints help information
*
* ArrayList<String> options - command options
*/
public static void NewDir(ArrayList<String> options) {

String name = "";

for (String option: options) {
if (option.equals("-h"))
{
System.out.println("Command syntax:\n\tmd [-h] name\n\nCreates a new directory.");
return;

}
else
{
name = JTerm.currentDirectory + option;
}
}

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

}
101 changes: 101 additions & 0 deletions src/main/java/com/jterm/Files.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package main.java.com.jterm;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Files {

/*
* WriteFile() void
*
* Get input and write it to a file.
*
* ArrayList<String> options - command options
*
* -h
* Prints help information
*/
public static void WriteFile(ArrayList<String> options) {

String filename = "";

for (String option: options)
{
if (option.equals("-h"))
{
System.out.println("Command syntax:\n\twrite [-h] filename\n\nOpens an input prompt in which to write text to a new file.");
return;

}
else
{
filename = JTerm.currentDirectory + option;

}

}

try {
System.out.println("Enter file contents:\n");
BufferedReader inputStream = new BufferedReader(new InputStreamReader(System.in), 1);
String output = inputStream.readLine();

FileWriter fileWriter = new FileWriter(filename);
fileWriter.write(output);
fileWriter.close();

}
catch (IOException ioe)
{
System.out.println(ioe);

}

}

/*
* Delete() void
*
* Delete the specified file or directory.
*
* ArrayList<String> options - command options
*
* -h
* Prints help information
*/
public static void Delete(ArrayList<String> options) {

String filename = "";

for (String option: options)
{
if (option.equals("-h"))
{
System.out.println("Command syntax:\n\tdel [-h] file/directory\n\nDeletes the specified file or directory.");
return;

}
else
{
filename = JTerm.currentDirectory + option;

}

}

File dir = new File(filename);
if (!dir.exists()) {
System.out.println("ERROR: File/directory \"" + options.get(options.size() - 1) + "\" does not exist.");
return;

}

dir.delete();

}

}
Loading

0 comments on commit 2030b8b

Please sign in to comment.