aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorAria <me@aria.rip>2023-02-03 12:14:41 +0000
committerAria <me@aria.rip>2023-02-03 12:14:41 +0000
commita6c9dba25ad9204ebde302728eb2a75532497f37 (patch)
treea977882c817fb612511cdabce959d4de027c5b22 /main.go
initial commit
Diffstat (limited to 'main.go')
-rw-r--r--main.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..9656146
--- /dev/null
+++ b/main.go
@@ -0,0 +1,50 @@
+package main
+
+import (
+ "fmt"
+ "os"
+ "os/exec"
+ "syscall"
+
+ tea "github.com/charmbracelet/bubbletea"
+)
+
+type item struct {
+ title string
+ contents string
+}
+
+func (i item) Title() string { return i.title }
+func (i item) Description() string { return i.contents }
+func (i item) FilterValue() string { return i.title }
+
+func main() {
+ if e := runProgram(); e != nil {
+ fmt.Println(e)
+ os.Exit(1)
+ }
+}
+
+func runProgram() error {
+
+ model, err := tea.NewProgram(StartSelecting(), tea.WithMouseCellMotion()).Run()
+ if err != nil {
+ return fmt.Errorf("Error running program: %s", err)
+ }
+ if confirm, ok := model.(confirmModel); ok && confirm.doRun {
+ sh, err := exec.LookPath("sh")
+ if err != nil {
+ return fmt.Errorf("could not find sh: %s", err)
+ }
+
+ args := []string{"-v", "-c"}
+ args = append(args, "set -v; "+confirm.selected.contents)
+
+ err = syscall.Exec(sh, args, os.Environ())
+ if err != nil {
+ return fmt.Errorf("could not exec: %s", err)
+ }
+ }
+
+ return nil
+}