- switchterm
- General info
- Why build this?
- What does it do?
- Technologies
- Requirements
- Repository overview
- Overview of the code.
- Things to remember
- Reference Commands
- Special thanks
- Why Go?
- Just added
This project is a command line selection tool. It stores commands in a sqlite database and their tags
- Go never changes
- Wanted a easy quick way to run commands and search for them.
- Made a multi-part series on it
- part2
Project is created with:
- atomicgo.dev/keyboard - For pressing keys
- github.com/Masterminds/sprig - For template functions
- https://pkg.go.dev/modernc.org/sqlite - Basically for keeping state
- go 1.21 for gonew
*- clone it
git clone https://github.com/golangast/switchterm
-
- or
-
- install gonew to pull down project quickly
go install golang.org/x/tools/cmd/gonew@latest
-
- run gonew
gonew github.com/golangast/switchterm example.com/switchterm
-
- cd into switchterm
cd switchterm
-
- run the project
go run main.go
├── bash #where bash commands are generated
├── cmd #where cmd commands are generated
├── db #database for switchterm
├── loggers #loggers for switchterm
├── readmeimages #readmeimages for switchterm readme
├── switchtermer
│ ├── cmd #how cmd commands are generated
│ ├── data #data for switchterm (under construction)
│ ├── db #database for switchterm
│ ├── generate #generate switchterm
│ ├── settings #settings for switchterm
│ ├── switch #main switch fuctions
│ └── window #window for switch
- allows for the user to select one from multiple values
answer := DigSingle(lists, 1, "green", "red")
- allows for the user to select many from multiple values
answer := Dig(lists, 1, "green", "red")
- prints the selection and formats it.
switchutility.PrintColumnsWChosen(cols, atline, results, background, foreground)
- allows you to ask a question and save the value
fmt.Println("add a commnd..")
scanner := bufio.NewScanner(os.Stdin)
scanner.Scan()
inputcmd := scanner.Text()
- prints the directions and clears the terminal
switchutility.ClearDirections()
- allows you to start the keyboard key press selecting
err := keyboard.Listen(func(key keys.Key) (stop bool, err error) {
switch key.String() {
*improved library sugar syntax
- to display a list of values to be chosen
domainanswer := switchselector.MenuInstuctions(ds, 1, "purple", "purple", "which domain do you prefer to use?")
- to ask a question and store the answer
datafields := switchutility.InputScanDirections("Whats the fields of the data? ")
- to run bash commands to usually pull down imports.
if err := switchutility.ShellBash("cd genserv/ && go run ."); err != nil {
switchutility.Checklogger(err, "running certification")
}
- to update text in a file.
if err := switchutility.UpdateText("dirtory/file.go", "text to check for", "what you are replacing", "text to do replacing"); err != nil {
switchutility.Checklogger(err, "message for the error")
}
- using atomicgo.dev/keyboard there is no way to call itself after a key press
- Remember to run the database server. It is under the generate command
- If you are using digital ocean
- Remember to generate certs
- Remember to change their permissions sudo chmod 755 /etc/letsencrypt/live/yourdomain/*.pem # Adjust if file names differ
- Remember to run the database in /bin
./rqlited -auth config.json -http-addr yourdomain.com:25060 -http-cert /etc/letsencrypt/live/yourdomain.com/fullchain.pem -http-key /etc/letsencrypt/live/yourdomain.com/privkey.pem ~/node.1
- "enter" is to select
- "c" is to select many
- "r" is to remove
- "x" is to execute
- "q" is to quit
- Just added to the genserv not the switchterm (did not add support for database https yet)
- rqlite
- gorqlite
- GNU 3 for my code
- MIT License for atomicgo keyboard
- MIT License for sprig
- BSD-3-Clause for sqlite driver
- BSD-3-Clause for Go itself
- Go Team because they are gods
- Creators of https://pkg.go.dev/modernc.org/sqlite -
- Creators of https://github.com/Masterminds/sprig-
- Creators of https://github.com/atomicgo/keyboard -
- The language is done since 1.0.https://youtu.be/rFejpH_tAHM there are little features that get added after 10 years but whatever you learn now will forever be useful.
- It also has a compatibility promise https://go.dev/doc/go1compat
- It was also built by great people. https://hackernoon.com/why-go-ef8850dc5f3c
- 14th used language https://insights.stackoverflow.com/survey/2021
- Highest starred language https://github.com/golang/go
- It is also number 1 language to go to and not from https://www.jetbrains.com/lp/devecosystem-2021/#Do-you-plan-to-adopt--migrate-to-other-languages-in-the-next--months-If-so-to-which-ones
- Go is growing in all measures https://madnight.github.io/githut/#/stars/2023/3
- Jobs are almost doubling every year. https://stacktrends.dev/technologies/programming-languages/golang/
- Companies that use go. https://go.dev/wiki/GoUsers
- Why I picked Go https://youtu.be/fD005g07cU4