Skip to content

Commit

Permalink
Partial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdhilahiRWabwire committed Jan 7, 2025
1 parent 56662a1 commit 4d89379
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 12 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion server/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 11 additions & 2 deletions server/source/command/argument_tokenizer.go
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
}
57 changes: 57 additions & 0 deletions server/source/command/user_input.go
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)
}
}
}
10 changes: 2 additions & 8 deletions server/source/main.go
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"

Check failure on line 4 in server/source/main.go

View workflow job for this annotation

GitHub Actions / build

package data-interchange-server/source/network is not in GOROOT (/opt/hostedtoolcache/go/1.20.14/x64/src/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()
}
16 changes: 16 additions & 0 deletions server/source/network/serve_application.go
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)
}
13 changes: 13 additions & 0 deletions server/source/utility/print_version.go
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")
}

0 comments on commit 4d89379

Please sign in to comment.