Compare commits
6 Commits
3e9e17323d
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 850efbe00f | |||
| b992353b02 | |||
| 0a889f38d4 | |||
| 4bf639f080 | |||
| a10b632f9d | |||
| a7183cd560 |
@@ -65,7 +65,8 @@ The client uses the following flags
|
|||||||
-ip <ip:port> - specify alternate server destination
|
-ip <ip:port> - specify alternate server destination
|
||||||
-l - list all quotes
|
-l - list all quotes
|
||||||
-r [i] - remove; may be run with or without argument
|
-r [i] - remove; may be run with or without argument
|
||||||
-e - edit
|
-e [i] - edit; may be run with or without argument
|
||||||
|
-c - list color format specifiers with examples
|
||||||
-s <i> - specify the size of the receipt buffer
|
-s <i> - specify the size of the receipt buffer
|
||||||
-v - display version and exit
|
-v - display version and exit
|
||||||
-vv - display version and about info and exit
|
-vv - display version and about info and exit
|
||||||
@@ -82,7 +83,6 @@ The server uses the following flags
|
|||||||
- Log all uses/transaction data each day
|
- Log all uses/transaction data each day
|
||||||
- Request, send, and receive the logfile
|
- Request, send, and receive the logfile
|
||||||
- User-specific quotes/quotefiles
|
- User-specific quotes/quotefiles
|
||||||
- Colored printing and coloring quotes
|
|
||||||
|
|
||||||
[golang]: <https://go.dev/doc/install>
|
[golang]: <https://go.dev/doc/install>
|
||||||
[just]: <https://github.com/casey/just>
|
[just]: <https://github.com/casey/just>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// =============================================================================
|
// =============================================================================
|
||||||
// Auth: alex
|
// Auth: alex
|
||||||
// File: client.go
|
// File: client.go
|
||||||
// Revn: 09-12-2026 3.0.2
|
// Revn: 09-16-2026 4.0.0
|
||||||
// Func: ask server for a message of the day quote
|
// Func: ask server for a message of the day quote
|
||||||
//
|
//
|
||||||
// TODO: remove ioutil import
|
// TODO: remove ioutil import
|
||||||
@@ -46,7 +46,13 @@
|
|||||||
// 09-07-2026: added fatih/color import
|
// 09-07-2026: added fatih/color import
|
||||||
// rewrote quoteAnswer() to handle coloring escape
|
// rewrote quoteAnswer() to handle coloring escape
|
||||||
// sequences
|
// sequences
|
||||||
// 09-12-2026: commented quoteAnswer()
|
//*09-12-2026: commented quoteAnswer()
|
||||||
|
//*09-15-2026: added -c flag and color code example printing
|
||||||
|
// changed edit command to be add and then remove instead
|
||||||
|
// of remove and then add, fixing server OOB error when
|
||||||
|
// editting only quote in list
|
||||||
|
//#09-15-2026: finished pretty print implementation
|
||||||
|
// made listAnswer() print list with color print
|
||||||
//
|
//
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|
||||||
@@ -242,7 +248,7 @@ func quoteAnswer( subcom []string ) string {
|
|||||||
|
|
||||||
c.Println() // print final newline
|
c.Println() // print final newline
|
||||||
|
|
||||||
fmt.Println( subcom[0] ) // whole-ass just print quote
|
//fmt.Println( subcom[0] ) // whole-ass just print quote
|
||||||
return "te@success" // set transaction end message
|
return "te@success" // set transaction end message
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,7 +322,8 @@ func listAnswer( subcom []string ) string {
|
|||||||
quotes := strings.Split( subcom[0], "\n" )
|
quotes := strings.Split( subcom[0], "\n" )
|
||||||
for p, v := range quotes { // iterate over quotes
|
for p, v := range quotes { // iterate over quotes
|
||||||
// print num of quote, followed by that quote
|
// print num of quote, followed by that quote
|
||||||
fmt.Println( p + 1, "\t", v )
|
fmt.Print( p + 1, "\t" )
|
||||||
|
quoteAnswer( []string{ v } )
|
||||||
}
|
}
|
||||||
resp = "te@success" // set transaction end message
|
resp = "te@success" // set transaction end message
|
||||||
}
|
}
|
||||||
@@ -388,16 +395,18 @@ func secondEdit( subcom []string ) string {
|
|||||||
return "te@success"
|
return "te@success"
|
||||||
}
|
}
|
||||||
|
|
||||||
// edit command is a removal and an add
|
// edit command is an add and then a removal
|
||||||
var resp string
|
var resp string
|
||||||
resp = "cr@r2@" + subcom[0] + "@ar@"
|
resp = "cr@ar@"
|
||||||
// server response is text to be edited
|
|
||||||
fmt.Println( "as is: " + subcom[1] )
|
fmt.Println( "as is: " + subcom[1] )
|
||||||
fmt.Print( "preview: " ) // won't be useful until pretty print
|
fmt.Print( "preview: " ) // show raw of current quote
|
||||||
_ = quoteAnswer( subcom[1:] ) // display quote properly
|
_ = quoteAnswer( subcom[1:] ) // display quote properly
|
||||||
|
|
||||||
// get user input for new quote and send
|
// server response is user input for new quote
|
||||||
resp = resp + in( "\nupdate -> " )
|
resp = resp + in( "\nupdate -> " )
|
||||||
|
// and position of old quote to be removed
|
||||||
|
resp = resp + "@r2@" + subcom[0]
|
||||||
return resp
|
return resp
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -558,6 +567,7 @@ var add bool // add new quotes to quote file ( on server )
|
|||||||
var remove bool // remove quotes from quote file ( on server )
|
var remove bool // remove quotes from quote file ( on server )
|
||||||
var list bool // request entire quote file from server
|
var list bool // request entire quote file from server
|
||||||
var edit bool // edit a pre-existing quote from quote file ( on server )
|
var edit bool // edit a pre-existing quote from quote file ( on server )
|
||||||
|
var co bool // list color codes
|
||||||
var dest string // provide a new destination ip and port
|
var dest string // provide a new destination ip and port
|
||||||
var tsize int // size of transmission buffer
|
var tsize int // size of transmission buffer
|
||||||
var VERS string // version
|
var VERS string // version
|
||||||
@@ -568,18 +578,19 @@ func main() {
|
|||||||
var vv bool // big version flag
|
var vv bool // big version flag
|
||||||
|
|
||||||
// define flags
|
// define flags
|
||||||
flag.BoolVar( &add, "a", false, "add quote to list" )
|
flag.BoolVar( &add, "a", false, "add quote to list" )
|
||||||
flag.BoolVar( &remove, "r", false, "remove quote from list" )
|
flag.BoolVar( &remove, "r", false, "remove quote from list" )
|
||||||
flag.BoolVar( &list, "l", false, "print quote list" )
|
flag.BoolVar( &list, "l", false, "print quote list" )
|
||||||
flag.BoolVar( &edit, "e", false, "edit quote from list" )
|
flag.BoolVar( &edit, "e", false, "edit quote from list" )
|
||||||
flag.StringVar( &dest, "ip", "127.0.0.1:1300", "ip:port of server" )
|
flag.BoolVar( &co, "c", false, "list color codes with examples" )
|
||||||
flag.IntVar( &tsize, "s", 256, "transmission size ( bytes )" )
|
flag.StringVar( &dest, "ip", "127.0.0.1:1300", "ip:port of server" )
|
||||||
flag.BoolVar( &v, "v", false, "display version and exit" )
|
flag.IntVar( &tsize, "s", 256, "transmission size ( bytes )" )
|
||||||
flag.BoolVar( &vv, "vv", false, "display version and about info and exit" )
|
flag.BoolVar( &v, "v", false, "display version and exit" )
|
||||||
|
flag.BoolVar( &vv, "vv", false, "display version and about info and exit" )
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
// FIXME get better versioning method
|
// FIXME get better versioning method
|
||||||
VERS = "3.0.2"
|
VERS = "4.0.0"
|
||||||
|
|
||||||
if vv { // display info and exit
|
if vv { // display info and exit
|
||||||
fmt.Println( "ekho client v" + VERS )
|
fmt.Println( "ekho client v" + VERS )
|
||||||
@@ -592,6 +603,54 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if co { // display color codes and examples and quit
|
||||||
|
// print color code and color example on same line
|
||||||
|
// color.XYZ print inserts newline
|
||||||
|
fmt.Print( "$1: " )
|
||||||
|
color.Red( "red" )
|
||||||
|
fmt.Print( "$2: " )
|
||||||
|
color.Yellow( "yellow" )
|
||||||
|
fmt.Print( "$3: " )
|
||||||
|
color.Green( "green" )
|
||||||
|
fmt.Print( "$4: " )
|
||||||
|
color.Blue( "blue" )
|
||||||
|
fmt.Print( "$5: " )
|
||||||
|
color.Cyan( "cyan" )
|
||||||
|
fmt.Print( "$6: " )
|
||||||
|
color.Magenta( "magenta" )
|
||||||
|
fmt.Print( "$7: " )
|
||||||
|
color.Black( "black" )
|
||||||
|
fmt.Print( "$0: " )
|
||||||
|
color.White( "white (reset)" )
|
||||||
|
// print bold codes
|
||||||
|
fmt.Print( "\n#1: " )
|
||||||
|
// create bold color object, change out actual color and print
|
||||||
|
bold := color.New( color.Bold, color.FgRed )
|
||||||
|
bold.Println( "bold red" )
|
||||||
|
fmt.Print( "#2: " )
|
||||||
|
bold.Add( color.FgYellow )
|
||||||
|
bold.Println( "bold yellow" )
|
||||||
|
fmt.Print( "#3: " )
|
||||||
|
bold.Add( color.FgGreen )
|
||||||
|
bold.Println( "bold green" )
|
||||||
|
fmt.Print( "#4: " )
|
||||||
|
bold.Add( color.FgBlue )
|
||||||
|
bold.Println( "bold blue" )
|
||||||
|
fmt.Print( "#5: " )
|
||||||
|
bold.Add( color.FgCyan )
|
||||||
|
bold.Println( "bold Cyan" )
|
||||||
|
fmt.Print( "#6: " )
|
||||||
|
bold.Add( color.FgMagenta )
|
||||||
|
bold.Println( "bold magenta" )
|
||||||
|
fmt.Print( "#7: " )
|
||||||
|
bold.Add( color.FgBlack )
|
||||||
|
bold.Println( "bold black" )
|
||||||
|
fmt.Print( "#0: " )
|
||||||
|
bold.Add( color.FgWhite )
|
||||||
|
bold.Println( "bold white" )
|
||||||
|
return // bail
|
||||||
|
}
|
||||||
|
|
||||||
service := dest // declare server ip:port
|
service := dest // declare server ip:port
|
||||||
|
|
||||||
// create address object
|
// create address object
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ ins_server:
|
|||||||
echo "systemctl status ekho"
|
echo "systemctl status ekho"
|
||||||
systemctl status ekho
|
systemctl status ekho
|
||||||
|
|
||||||
|
|
||||||
# install client
|
# install client
|
||||||
ins_client:
|
ins_client:
|
||||||
#!/usr/bin/bash
|
#!/usr/bin/bash
|
||||||
@@ -67,3 +66,57 @@ ins_client:
|
|||||||
mv ekho /usr/local/bin/
|
mv ekho /usr/local/bin/
|
||||||
echo "add 'ekho' to shell config (config.fish, .bashrc, etc)"
|
echo "add 'ekho' to shell config (config.fish, .bashrc, etc)"
|
||||||
|
|
||||||
|
# test server
|
||||||
|
stest:
|
||||||
|
@echo "creating server test session"
|
||||||
|
@tmux new-session -Ad -s "server test"
|
||||||
|
@tmux split-window -h -t "server test:1" -l 10%
|
||||||
|
@tmux split-window -v -t "server test:1.2"
|
||||||
|
@tmux send-keys -t "server test:1.1" "clear" Enter
|
||||||
|
@tmux send-keys -t "server test:1.2" "clear" Enter
|
||||||
|
@tmux send-keys -t "server test:1.3" "clear" Enter
|
||||||
|
@tmux rename-window "server test"
|
||||||
|
@tmux send-keys -t "server test:1.1" "vim server.go" Enter
|
||||||
|
@tmux send-keys -t "server test:1.2" "./server"
|
||||||
|
@tmux send-keys -t "server test:1.3" "./client"
|
||||||
|
@tmux attach -t "server test"
|
||||||
|
|
||||||
|
# test client
|
||||||
|
ctest:
|
||||||
|
@echo "creating client test session"
|
||||||
|
@tmux new-session -Ad -s "client test"
|
||||||
|
@tmux split-window -h -t "client test:1" -l 10%
|
||||||
|
@tmux split-window -v -t "client test:1.2"
|
||||||
|
@tmux send-keys -t "client test:1.1" "clear" Enter
|
||||||
|
@tmux send-keys -t "client test:1.2" "clear" Enter
|
||||||
|
@tmux send-keys -t "client test:1.3" "clear" Enter
|
||||||
|
@tmux rename-window "client test"
|
||||||
|
@tmux send-keys -t "client test:1.1" "vim client.go" Enter
|
||||||
|
@tmux send-keys -t "client test:1.2" "./server" Enter
|
||||||
|
@tmux send-keys -t "client test:1.3" "./client"
|
||||||
|
@tmux attach -t "client test"
|
||||||
|
|
||||||
|
# dev work
|
||||||
|
dev:
|
||||||
|
#!/usr/bin/bash
|
||||||
|
REPO=$(basename $(git rev-parse --show-toplevel))
|
||||||
|
BRANCH=$(git branch --show-current)
|
||||||
|
tmux has-session -t "$REPO->$BRANCH"
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
tmux attach-session -t "$REPO->$BRANCH"
|
||||||
|
else
|
||||||
|
tmux new-session -Ad -s "$REPO->$BRANCH"
|
||||||
|
tmux rename-window "write"
|
||||||
|
tmux new-window -a -t 1 -n "test"
|
||||||
|
tmux new-window -a -t 2 -n "git" lazygit
|
||||||
|
tmux new-window -a -t 3 -n "man"
|
||||||
|
tmux select-window -t 2
|
||||||
|
tmux select-window -t 1
|
||||||
|
tmux attach -t "$REPO->$BRANCH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# prep repo to be committed
|
||||||
|
prep:
|
||||||
|
mv justfile test_justfile
|
||||||
|
mv prod_justfile justfile
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
// =============================================================================
|
// =============================================================================
|
||||||
// Auth: alex
|
// Auth: alex
|
||||||
// File: server.go
|
// File: server.go
|
||||||
// Revn: 09-12-2026 3.0.1
|
// Revn: 09-15-2026 3.0.2
|
||||||
// Func: host MOTD connection
|
// Func: host MOTD connection
|
||||||
//
|
//
|
||||||
// TODO: add user-specific prints
|
// TODO: add user-specific prints
|
||||||
// write usage and errors to logfile
|
// write usage and errors to logfile
|
||||||
// remove ioutil import
|
// remove ioutil import
|
||||||
// send logfile to client on request
|
// send logfile to client on request
|
||||||
// add color printing to qfile
|
|
||||||
// add flags?
|
// add flags?
|
||||||
// add more /codes/ to handle
|
// add more /codes/ to handle
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
@@ -53,6 +52,8 @@
|
|||||||
// 09-05-2026: buncha shit happened, dropped the commit
|
// 09-05-2026: buncha shit happened, dropped the commit
|
||||||
//#09-06-2026: added /e1/, /e2/, and /cr/, got edit working
|
//#09-06-2026: added /e1/, /e2/, and /cr/, got edit working
|
||||||
// 09-12-2026: minor comments in receive()
|
// 09-12-2026: minor comments in receive()
|
||||||
|
//*09-15-2026: fixed OOB error in /qa/ for perhaps the last time
|
||||||
|
// fixed bad Atoi conversion bug for perhaps the last time
|
||||||
//
|
//
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|
||||||
@@ -187,7 +188,7 @@ func handle( command []string ) string {
|
|||||||
case "qr": // /qr/, quote request
|
case "qr": // /qr/, quote request
|
||||||
// convert message argument to string to make sure it's a
|
// convert message argument to string to make sure it's a
|
||||||
// valid number
|
// valid number
|
||||||
num, nerr := strconv.Atoi( command[0] )
|
num, nerr := strconv.Atoi( command[1] )
|
||||||
// nerr will not be nil if comm[1] is not a number
|
// nerr will not be nil if comm[1] is not a number
|
||||||
if nerr != nil {
|
if nerr != nil {
|
||||||
// formulate an error message
|
// formulate an error message
|
||||||
@@ -205,7 +206,7 @@ func handle( command []string ) string {
|
|||||||
// why bad? num is -
|
// why bad? num is -
|
||||||
default:
|
default:
|
||||||
// good num, get quote, send off
|
// good num, get quote, send off
|
||||||
resp = "qa@" + qlist[num - 1] // quote answer
|
resp = "qa@" + qlist[num] // quote answer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "lr": // /lr/, list request
|
case "lr": // /lr/, list request
|
||||||
@@ -453,7 +454,7 @@ func main() {
|
|||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
// FIXME get better versioning method
|
// FIXME get better versioning method
|
||||||
VERS = "3.0.1"
|
VERS = "3.0.2"
|
||||||
|
|
||||||
if vv { // display info and exit
|
if vv { // display info and exit
|
||||||
fmt.Println( "ekho server v" + VERS )
|
fmt.Println( "ekho server v" + VERS )
|
||||||
|
|||||||
Reference in New Issue
Block a user