Skip to content

Commit 2030b8b

Browse files
authored
Merge pull request #5 from Sergix/dev
Release v0.3.0
2 parents 2daeaec + 3642d0a commit 2030b8b

12 files changed

+655
-44
lines changed
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Changelog entry:
2+
3+
[6/4/2017-20:08 0.3.0 Sergix]
4+
Release 0.3.0 has been pushed with the associated documentation and other data.
5+
Documentation now includes a section covering commands that JTerm provides.
6+
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.
7+
Pushed updates to Git.
8+
9+
Full changes include:
10+
- Created "Client" class
11+
- Added "connect" command; called with `Client.Connect()` function
12+
- NOT FUNCTIONING in this release; source is included
13+
- Created "Server" class
14+
- Added "server" command; called with `Server.Start()` function
15+
- NOT FUNCTIONING in this release; source is included
16+
- Created "Window" class
17+
- Added "window" command; called with `new Window()` function
18+
- Added the "md" command (Make Directory) that calls the new `Dir.NewDir()` function
19+
- Added the "del" command (DELete) that calls the new `Files.Delete()` function
20+
- In-development source code is now pushed to the `dev` branch on the repository, which will be merged with `master` on release
21+
- Inputed commands convert to all lowercase
22+
- `Write` class has been removed; member function moved to `Files` class
23+
- The current directory will always end with a single "forward slash" (e.g. `/usr/home/`)
24+
- Other minor fixes
25+
26+
More information provided in published release documentation.

build/jar/jterm-v0.3.0.jar

13.9 KB
Binary file not shown.

build/src/jterm-src-v0.3.0.zip

21.2 KB
Binary file not shown.

changelog.txt

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
- Added command option parsing for WriteFile
2222
- Made inputed commands (not options) default to lowercase
2323
- Files.Delete deletes both files AND directories
24-
-
2524
Created "dev" branch that will be used for development.
2625
Fixed incorrect date in last changelog entry.
2726

docs/release/jterm-v0.3.0-docs.md

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# JTerm Documentation v0.3.0
2+
3+
## Table of Contents
4+
```
5+
I. Table of Contents
6+
II. Overview
7+
III. Build Targets
8+
IV. Changelog
9+
V. New Features
10+
A. Commands
11+
B. Client/Server
12+
VI. Active Command List
13+
```
14+
15+
## Overview
16+
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.
17+
18+
## Build Targets
19+
```
20+
[VERSION] [FILE] [STATE]
21+
0.1.0 jterm-v0.1.0.jar OK
22+
0.2.0 jterm-v0.2.0.jar OK
23+
0.2.1 jterm-v0.2.1.jar OK
24+
0.3.0 jterm-v0.3.0.jar OK
25+
```
26+
27+
## Changelog
28+
- Created "Client" class
29+
- Added "connect" command; called with `Client.Connect()` function
30+
- NOT FUNCTIONING in this release; source is included
31+
- Created "Server" class
32+
- Added "server" command; called with `Server.Start()` function
33+
- NOT FUNCTIONING in this release; source is included
34+
- Created "Window" class
35+
- Added "window" command; called with `new Window()` function
36+
- Added the "md" command (Make Directory) that calls the new `Dir.NewDir()` function
37+
- Added the "del" command (DELete) that calls the new `Files.Delete()` function
38+
- In-development source code is now pushed to the `dev` branch on the repository, which will be merged with `master` on release
39+
- Inputed commands convert to all lowercase
40+
- `Write` class has been removed; member function moved to `Files` class
41+
- The current directory will always end with a single "forward slash" (e.g. `/usr/home/`)
42+
- Other minor fixes
43+
44+
## New Features
45+
46+
### Commands
47+
The commands `connect`, `server`, `md`, `del`, and `window` have been added to JTerm. The syntax for these commands are as follows:
48+
```
49+
connect [-h] [-p port] address
50+
server [-h] port
51+
md [-h] name
52+
del [-h] file/directory
53+
window [-h] [-r] [-w width] [-l height] [-t title]
54+
```
55+
`connect` AND `server` ARE NOT FUNCTIONABLE IN THIS RELEASE.
56+
`-h` ALWAYS displays the command's help information in the console. `-r`, used for the `window` command, toggles resizability for the created window.
57+
58+
### Client/Server
59+
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.
60+
61+
## Active Command List
62+
- `help` - displays information about JTerm
63+
- `quit` - Exits the JTerm application
64+
- `write [-h] filename` - Opens an input prompt that will write the data to the new file named `filename`
65+
- `dir [-f] [-h] [directory]` - Dispays extensive directory information, including files and subdirectories
66+
- `-f` - toggles minimal output
67+
- `cd [-h] directory` - Changes the directory to the location specified
68+
- `pwd` - prints the current working directory
69+
- `echo [-h] input` - outputs the input on a new line
70+
- `del [-h] file/directory` - deletes the specified file or directory
71+
- `md [-h] name` - creates a new directory
72+
- `window [-h] [-r] [-w width] [-l height] [-t title]` - creates a new GUI window
73+
- `-r` - toggles resizability
74+
- `-w` - specifies window width
75+
- `-l` - specifies window height
76+
- `-t` - sets the name of the window, displayed in the title bar
77+
78+
> JTerm 0.3.0
79+
> `jterm-v0.3.0.jar`
80+
> This project and its source are held under the GNU General Public License, located in the LICENSE file in the project's directory.
81+
> (c) 2017

src/main/java/com/jterm/Client.java

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
package main.java.com.jterm;
2+
3+
import java.io.*;
4+
import java.net.Socket;
5+
import java.util.ArrayList;
6+
7+
public class Client implements Runnable {
8+
9+
private static BufferedReader input;
10+
11+
public void run() {
12+
13+
while (true) {
14+
try {
15+
String output = Client.input.readLine();
16+
if (output != null)
17+
System.out.println(output);
18+
19+
} catch (IOException ioe) {
20+
return;
21+
22+
}
23+
24+
}
25+
26+
}
27+
28+
public static void Connect(ArrayList<String> options) {
29+
30+
String address = "0.0.0.0";
31+
String portInput = "80";
32+
boolean next = false;
33+
34+
for (String option: options) {
35+
if (option.equals("-h"))
36+
{
37+
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.");
38+
return;
39+
40+
}
41+
else if (option.equals("-p"))
42+
{
43+
next = true;
44+
45+
}
46+
else if (next)
47+
{
48+
portInput = option;
49+
next = false;
50+
51+
}
52+
else
53+
{
54+
address = option;
55+
56+
}
57+
58+
}
59+
60+
int i = 0;
61+
int port = 0;
62+
63+
while( i < portInput.length())
64+
{
65+
port *= 10;
66+
port += portInput.charAt(i++) - '0';
67+
68+
}
69+
70+
try {
71+
System.out.println("Connecting to " + address + ":" + port);
72+
73+
Socket connection = new Socket(address, port);
74+
InputStream input = connection.getInputStream();
75+
OutputStream output = connection.getOutputStream();
76+
BufferedReader bufferedSocketInput = new BufferedReader(new InputStreamReader(input));
77+
78+
Client.input = bufferedSocketInput;
79+
80+
Client client = new Client();
81+
Thread readThread = new Thread(client);
82+
readThread.start();
83+
84+
System.out.println("Connected to server. Enter a blank line to quit. Reading for input...");
85+
86+
while (true) {
87+
BufferedReader bufferedSocketOutput = new BufferedReader(new InputStreamReader(System.in), 1);
88+
String line = bufferedSocketOutput.readLine();
89+
90+
if (line.equals(""))
91+
break;
92+
output.write(line.getBytes());
93+
94+
output.close();
95+
bufferedSocketOutput.close();
96+
97+
}
98+
99+
connection.close();
100+
101+
}
102+
catch (IOException ioe)
103+
{
104+
System.out.println("Connection severed.");
105+
106+
}
107+
108+
}
109+
110+
}

src/main/java/com/jterm/Dir.java

+46-1
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,25 @@ public static void ChangeDir(ArrayList<String> options) {
126126

127127
// Test if the input exists and if it is a directory
128128
File dir = new File(newDirectory);
129-
if (!dir.exists() || !dir.isDirectory()) {
129+
File newDir = new File(JTerm.currentDirectory + newDirectory);
130+
131+
if (newDir.exists() && newDir.isDirectory()) {
132+
newDirectory = JTerm.currentDirectory + newDirectory;
133+
134+
}
135+
else if ((!dir.exists() || !dir.isDirectory()) && (!newDir.exists() || !newDir.isDirectory()))
136+
{
130137
System.out.println("ERROR: Directory \"" + newDirectory + "\" is either does not exist or is not a valid directory.");
131138
return;
132139

133140
}
134141

142+
if (!newDirectory.endsWith("/"))
143+
{
144+
newDirectory += "/";
145+
146+
}
147+
135148
// It does exist, and it is a directory, so just change the global working directory variable to the input
136149
JTerm.currentDirectory = newDirectory;
137150

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

165178
}
179+
180+
/*
181+
* NewDir() void
182+
*
183+
* Creates a new directory.
184+
*
185+
* -h
186+
* Prints help information
187+
*
188+
* ArrayList<String> options - command options
189+
*/
190+
public static void NewDir(ArrayList<String> options) {
191+
192+
String name = "";
193+
194+
for (String option: options) {
195+
if (option.equals("-h"))
196+
{
197+
System.out.println("Command syntax:\n\tmd [-h] name\n\nCreates a new directory.");
198+
return;
199+
200+
}
201+
else
202+
{
203+
name = JTerm.currentDirectory + option;
204+
}
205+
}
206+
207+
File dir = new File(name);
208+
dir.mkdir();
209+
}
210+
166211
}

src/main/java/com/jterm/Files.java

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
package main.java.com.jterm;
2+
3+
import java.io.BufferedReader;
4+
import java.io.File;
5+
import java.io.FileWriter;
6+
import java.io.IOException;
7+
import java.io.InputStreamReader;
8+
import java.util.ArrayList;
9+
10+
public class Files {
11+
12+
/*
13+
* WriteFile() void
14+
*
15+
* Get input and write it to a file.
16+
*
17+
* ArrayList<String> options - command options
18+
*
19+
* -h
20+
* Prints help information
21+
*/
22+
public static void WriteFile(ArrayList<String> options) {
23+
24+
String filename = "";
25+
26+
for (String option: options)
27+
{
28+
if (option.equals("-h"))
29+
{
30+
System.out.println("Command syntax:\n\twrite [-h] filename\n\nOpens an input prompt in which to write text to a new file.");
31+
return;
32+
33+
}
34+
else
35+
{
36+
filename = JTerm.currentDirectory + option;
37+
38+
}
39+
40+
}
41+
42+
try {
43+
System.out.println("Enter file contents:\n");
44+
BufferedReader inputStream = new BufferedReader(new InputStreamReader(System.in), 1);
45+
String output = inputStream.readLine();
46+
47+
FileWriter fileWriter = new FileWriter(filename);
48+
fileWriter.write(output);
49+
fileWriter.close();
50+
51+
}
52+
catch (IOException ioe)
53+
{
54+
System.out.println(ioe);
55+
56+
}
57+
58+
}
59+
60+
/*
61+
* Delete() void
62+
*
63+
* Delete the specified file or directory.
64+
*
65+
* ArrayList<String> options - command options
66+
*
67+
* -h
68+
* Prints help information
69+
*/
70+
public static void Delete(ArrayList<String> options) {
71+
72+
String filename = "";
73+
74+
for (String option: options)
75+
{
76+
if (option.equals("-h"))
77+
{
78+
System.out.println("Command syntax:\n\tdel [-h] file/directory\n\nDeletes the specified file or directory.");
79+
return;
80+
81+
}
82+
else
83+
{
84+
filename = JTerm.currentDirectory + option;
85+
86+
}
87+
88+
}
89+
90+
File dir = new File(filename);
91+
if (!dir.exists()) {
92+
System.out.println("ERROR: File/directory \"" + options.get(options.size() - 1) + "\" does not exist.");
93+
return;
94+
95+
}
96+
97+
dir.delete();
98+
99+
}
100+
101+
}

0 commit comments

Comments
 (0)