From 4d893799d7114aab7559ab29178bb5bfa490c17c Mon Sep 17 00:00:00 2001 From: Abdhilahi Wabwire <124460109+AbdhilahiRWabwire@users.noreply.github.com> Date: Mon, 6 Jan 2025 20:00:46 -0700 Subject: [PATCH] Partial Commit --- README.md | 3 +- server/.gitignore | 2 +- server/source/command/argument_tokenizer.go | 13 ++++- server/source/command/user_input.go | 57 +++++++++++++++++++++ server/source/main.go | 10 +--- server/source/network/serve_application.go | 16 ++++++ server/source/utility/print_version.go | 13 +++++ 7 files changed, 102 insertions(+), 12 deletions(-) create mode 100644 server/source/command/user_input.go create mode 100644 server/source/network/serve_application.go create mode 100644 server/source/utility/print_version.go diff --git a/README.md b/README.md index 34d30bc..f84ca35 100755 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [CommonMark]:https://commonmark.org/ -[Dart]: https://dart.dev/ +[Fleet]: https://jetbrains.com/fleet [Go Language]: https://go.dev [HTTP]: https://developer.mozilla.org/en-US/docs/Web/HTTP [JavaScript Language]: https://developer.mozilla.org/en-US/docs/Web/JavaScript @@ -43,6 +43,7 @@ Data Interchange is a Network Application Programming Interface Development Plat ## Build - [Go][Go Language] +- [JetBrains Fleet][Fleet] - [JetBrains Webstorm][Webstorm] - [JavaScript][JavaScript Language] - [Mozilla Developer Network Web Documentation][MDN] diff --git a/server/.gitignore b/server/.gitignore index 1b0b927..81e3303 100755 --- a/server/.gitignore +++ b/server/.gitignore @@ -17,7 +17,7 @@ build/ # Test binary, built with `go test -c` *.test -# Output of the go coverage tool, specifically when used with LiteIDE +# Output of the go coverage tool *.out # Dependency directories (remove the comment below to include it) diff --git a/server/source/command/argument_tokenizer.go b/server/source/command/argument_tokenizer.go index ef4d32d..d70552b 100755 --- a/server/source/command/argument_tokenizer.go +++ b/server/source/command/argument_tokenizer.go @@ -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 } diff --git a/server/source/command/user_input.go b/server/source/command/user_input.go new file mode 100644 index 0000000..0ff0315 --- /dev/null +++ b/server/source/command/user_input.go @@ -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) + } + } +} diff --git a/server/source/main.go b/server/source/main.go index 90a5381..f1100c6 100755 --- a/server/source/main.go +++ b/server/source/main.go @@ -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() } diff --git a/server/source/network/serve_application.go b/server/source/network/serve_application.go new file mode 100644 index 0000000..7878105 --- /dev/null +++ b/server/source/network/serve_application.go @@ -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) +} diff --git a/server/source/utility/print_version.go b/server/source/utility/print_version.go new file mode 100644 index 0000000..159eeb9 --- /dev/null +++ b/server/source/utility/print_version.go @@ -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") +}