-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
56662a1
commit 4d89379
Showing
7 changed files
with
102 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
package command | ||
|
||
// Command Line Argument Tokenizer | ||
type ArgumentTokenizer struct { | ||
import ( | ||
"strings" | ||
) | ||
|
||
// Tokenize Command Line Arguments from User Input | ||
func TokenizeArgumentInput(input string) []string { | ||
var toLowerCase string = strings.ToLower(input) | ||
|
||
var inputCommands []string = strings.Fields(toLowerCase) | ||
|
||
return inputCommands | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package command | ||
|
||
import ( | ||
"bufio" | ||
"data-interchange-server/source/network" | ||
"data-interchange-server/source/utility" | ||
"fmt" | ||
"os" | ||
) | ||
|
||
var userInput *bufio.Scanner = bufio.NewScanner(os.Stdin) | ||
|
||
var userInputText string = userInput.Text() | ||
|
||
var cleanUserInput []string = TokenizeArgumentInput(userInputText) | ||
|
||
var inputArguments string = cleanUserInput[0] | ||
|
||
// Command Line User Input | ||
func UserInput() { | ||
for { | ||
fmt.Println("Enter Command: ") | ||
|
||
userInput.Scan() | ||
|
||
if len(cleanUserInput) == 0 { | ||
continue | ||
} | ||
|
||
switch inputArguments { | ||
case "exit": | ||
os.Exit(0) | ||
case "help": | ||
fmt.Println("Hyaena Technologies: Data Interchange Server") | ||
fmt.Println("") | ||
fmt.Println("") | ||
fmt.Println("Commands: Description:") | ||
fmt.Println("") | ||
fmt.Println("exit Exit Server") | ||
fmt.Println("help Print List of Commands and Flags") | ||
fmt.Println("serve Serve Web Applcation") | ||
fmt.Println("version Print Version Number") | ||
fmt.Println("") | ||
fmt.Println("") | ||
fmt.Println("Flags: Description:") | ||
fmt.Println("") | ||
fmt.Println("--help, --h, -h Print List of Commands and Flags") | ||
fmt.Println("--version, --v, -v Print Version Number") | ||
case "serve": | ||
network.ServeWebApplication() | ||
case "version": | ||
utility.PrintVersionNumber() | ||
default: | ||
fmt.Println("Invalid Command: ", inputArguments) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,9 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"data-interchange-server/source/network" | ||
) | ||
|
||
const port string = ":8080" | ||
|
||
var fileServer http.Handler = http.FileServer(http.Dir("./source")) | ||
|
||
func main() { | ||
fmt.Println("Serving on Port: 8080") | ||
http.ListenAndServe(port, fileServer) | ||
network.ServeWebApplication() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package network | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
) | ||
|
||
const port string = ":8080" | ||
|
||
var fileServer http.Handler = http.FileServer(http.Dir("./source")) | ||
|
||
// Serve Web Application | ||
func ServeWebApplication() { | ||
fmt.Println("Serving on Port: 8080") | ||
http.ListenAndServe(port, fileServer) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package utility | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
// Print Version Number | ||
func PrintVersionNumber() { | ||
fmt.Println("Hyaena Technologies: Data Interchange Server") | ||
fmt.Println("") | ||
fmt.Println("") | ||
fmt.Println("Version Number: 0.2.0") | ||
} |