https://github.com/notcoffee418/goscriptoperations
Library to set up CLI with various operations
https://github.com/notcoffee418/goscriptoperations
Last synced: 6 months ago
JSON representation
Library to set up CLI with various operations
- Host: GitHub
- URL: https://github.com/notcoffee418/goscriptoperations
- Owner: NotCoffee418
- License: mit
- Created: 2024-09-12T23:16:34.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-13T00:42:47.000Z (almost 2 years ago)
- Last Synced: 2025-01-23T08:16:17.214Z (over 1 year ago)
- Language: Go
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go User Input Utility
Library for settign up CLI with multiple operations in a structured way.
## Features
- Boolean questions (yes/no)
- String input
- Integer input
- Float input
- Multiple choice questions
## Usage
Import the package in your Go project:
```go
import "github.com/NotCoffee418/goscriptoperations"
func main() {
// Register any operations
goscriptoperations.RegisterOperation(goscriptoperations.Operation{
Index: 1, // Not literal, just asc sorting order
Description: "Example Operation",
Function: someFunction,
})
// Start listening for user input and execute operations as prompted
goscriptoperations.StartListening()
}
```
```
# Output
Available Operations:
0. Exit the program
1. Example Operation
Enter operation number: 1
Executing operation 1
Example Operation Completed!
```
## UtilityFunctions
- `PoseBooleanQuestion`: Ask a yes/no question
- `PoseStringQuestion`: Ask for a string input
- `PoseIntQuestion`: Ask for an integer input
- `PoseFloatQuestion`: Ask for a float input
- `PoseChoiceQuestion`: Present a list of choices