SkillAgentSearch skills...

Switchterm

This is a cli tool to generate go functions, bash, go servers. It also allows you to tag these and search them.

Install / Use

/learn @golangast/Switchterm
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

switchterm

<p align="center"> <img style="width:60%;" src="./readmeimages/termglow.gif" alt="Alt text" title="Optional title"> </p>

GitHub repo file count GitHub code size in bytes GitHub repo size GitHub GitHub commit activity Go 100% status beta <img src="https://img.shields.io/github/license/golangast/switchterm.svg"><img src="https://img.shields.io/github/stars/golangast/switchterm.svg">Website shields.ioPRs WelcomeMaintenanceGitHub go.mod Go version of a Go moduleGoDoc reference exampleGoReportCard examplesaythanks

General info

This project is a command line selection tool. It stores commands in a sqlite database and their tags

Why build this?

  • Go never changes
  • Wanted a easy quick way to run commands and search for them.

What does it do?

  • Made a multi-part series on it
  • part2
<h1 align="center">Change the directory of the commands and run them</h1> <p align="center"> <img src="./readmeimages/changedir.gif" alt="Alt text" title="Optional title"> </p> <h1 align="center">You can even do search by tag</h1> <p align="center"> <img src="./readmeimages/search.gif" alt="Alt text" title="Optional title"> <h1 align="center">Run multiple commands</h1> <p align="center"> <img src="./readmeimages/ex.gif" alt="Alt text" title="Optional title"> </p> <h1 align="center">Make bash files and run arguments in them</h1> <p align="center"> <img src="./readmeimages/bash.gif" alt="Alt text" title="Optional title"> </p> <h1 align="center">Generate your server</h1> <p align="center"> <img src="./readmeimages/servers.gif" alt="Alt text" title="Optional title"> </p> <h1 align="center">Generate your get handlers</h1> <p align="center"> <img src="./readmeimages/handler.gif" alt="Alt text" title="Optional title"> </p> <h1 align="center">Generate your data and choose the Handler you want it to be connected to</h1> <p align="center"> <img src="./readmeimages/generatehandler.gif" alt="Alt text" title="Optional title"> </p>

Technologies

Project is created with:

Requirements

  • go 1.21 for gonew

How to run as is?

*- 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

Repository overview

├── 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

Overview of the code.

  1. allows for the user to select one from multiple values
answer := DigSingle(lists, 1, "green", "red")
  1. allows for the user to select many from multiple values
answer := Dig(lists, 1, "green", "red")

  1. prints the selection and formats it.
switchutility.PrintColumnsWChosen(cols, atline, results, background, foreground)
  1. 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()

  1. prints the directions and clears the terminal
 	switchutility.ClearDirections()
  1. 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

  1. to display a list of values to be chosen
	domainanswer := switchselector.MenuInstuctions(ds, 1, "purple", "purple", "which domain do you prefer to use?")
  1. to ask a question and store the answer
    datafields := switchutility.InputScanDirections("Whats the fields of the data? ")
  1. to run bash commands to usually pull down imports.
if err := switchutility.ShellBash("cd genserv/ && go run ."); err != nil {
		switchutility.Checklogger(err, "running certification")
	}
  1. 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")
	}

Things to remember

  • 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

Reference Commands

  • "enter" is to select
  • "c" is to select many
  • "r" is to remove
  • "x" is to execute
  • "q" is to quit

Just added

  • Just added to the genserv not the switchterm (did not add support for database https yet)
  • rqlite
  • gorqlite

Licenses

  1. GNU 3 for my code
  2. MIT License for atomicgo keyboard
  3. MIT License for sprig
  4. BSD-3-Clause for sqlite driver
  5. BSD-3-Clause for Go itself

Special thanks

Why Go?

  • 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
View on GitHub
GitHub Stars13
CategoryData
Updated8mo ago
Forks0

Languages

Go

Security Score

87/100

Audited on Aug 1, 2025

No findings