Start process to away from bubbletea to a more simpler solution for this projects needs
This commit is contained in:
parent
cc6db38d74
commit
c1ea5e5163
10 changed files with 298 additions and 65 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"bytes"
|
||||
"encoding/base64"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"time"
|
||||
|
||||
|
@ -88,3 +89,10 @@ func Elevate(password string) {
|
|||
err = cmd.Wait()
|
||||
errorcheck.ErrorCheck(err, "\nError, password given was wrong")
|
||||
}
|
||||
|
||||
// Function to just clear the terminal
|
||||
func Clear() {
|
||||
c := exec.Command("clear")
|
||||
c.Stdout = os.Stdout
|
||||
c.Run()
|
||||
}
|
||||
|
|
34
pkg/menu/genmenu.go
Normal file
34
pkg/menu/genmenu.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
package menu
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
|
||||
"github.com/gookit/color"
|
||||
"github.com/nexidian/gocliselect"
|
||||
)
|
||||
|
||||
func GenIOMMUMenu(msg string, choices []string) string {
|
||||
// Make a regex to get the iommu group
|
||||
iommu_group_regex := regexp.MustCompile(`(\d{1,3})`)
|
||||
|
||||
// Make the menu
|
||||
menu := gocliselect.NewMenu(msg)
|
||||
|
||||
// For each choice passed
|
||||
for _, choice := range choices {
|
||||
// Get the iommu group
|
||||
iommuGroup := iommu_group_regex.FindString(choice)
|
||||
|
||||
// Add the choice with shortened vendor name and the iommu group as the return value
|
||||
menu.AddItem(choice, iommuGroup)
|
||||
}
|
||||
|
||||
// Add a go back option
|
||||
menu.AddItem(color.Bold.Sprint("Go Back"), "back")
|
||||
|
||||
// Display the menu
|
||||
choice := menu.Display()
|
||||
|
||||
// Return the value selected
|
||||
return choice
|
||||
}
|
17
pkg/menu/next.go
Normal file
17
pkg/menu/next.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
package menu
|
||||
|
||||
import "github.com/nexidian/gocliselect"
|
||||
|
||||
// Make a Next menu
|
||||
func Next(msg string) string {
|
||||
// Make the menu
|
||||
menu := gocliselect.NewMenu(msg)
|
||||
menu.AddItem("Next", "next")
|
||||
menu.AddItem("Go Back", "back")
|
||||
|
||||
// Display the menu
|
||||
choice := menu.Display()
|
||||
|
||||
// Return the value selected
|
||||
return choice
|
||||
}
|
31
pkg/menu/yesno.go
Normal file
31
pkg/menu/yesno.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package menu
|
||||
|
||||
import "github.com/nexidian/gocliselect"
|
||||
|
||||
// Make a YesNo menu
|
||||
func YesNo(msg string) string {
|
||||
// Make the menu
|
||||
menu := gocliselect.NewMenu(msg)
|
||||
menu.AddItem("Yes", "y")
|
||||
menu.AddItem("No", "n")
|
||||
|
||||
// Display the menu
|
||||
choice := menu.Display()
|
||||
|
||||
// Return the value selected
|
||||
return choice
|
||||
}
|
||||
|
||||
func YesNoEXT(msg string) string {
|
||||
// Make the menu
|
||||
menu := gocliselect.NewMenu(msg)
|
||||
menu.AddItem("Yes", "y")
|
||||
menu.AddItem("No", "n")
|
||||
menu.AddItem("ADVANCED: View with extended related search by vendor ID, results will be inaccurate", "ext")
|
||||
|
||||
// Display the menu
|
||||
choice := menu.Display()
|
||||
|
||||
// Return the value selected
|
||||
return choice
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue