From 989b784fa8604e15481cf09258eee53d2c5a8798 Mon Sep 17 00:00:00 2001 From: Maas Lalani Date: Fri, 26 Jan 2024 12:07:40 -0500 Subject: [PATCH] interactive.go --- go.mod | 4 ++-- go.sum | 4 ++-- form.go => interactive.go | 10 ++++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) rename form.go => interactive.go (97%) diff --git a/go.mod b/go.mod index 61bde8c..1565c98 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/alecthomas/chroma v0.10.1-0.20220126230913-d491f1b5c1d2 github.com/alecthomas/kong v0.8.1 github.com/beevik/etree v1.3.0 - github.com/charmbracelet/huh v0.2.4-0.20240119002230-42853f5e6a3e + github.com/charmbracelet/huh v0.3.1-0.20240125205708-bb9c8f48a9f4 github.com/charmbracelet/lipgloss v0.9.1 github.com/charmbracelet/log v0.3.1 github.com/mattn/go-isatty v0.0.20 @@ -16,7 +16,7 @@ require ( github.com/atotto/clipboard v0.1.4 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/catppuccin/go v0.2.0 // indirect - github.com/charmbracelet/bubbles v0.17.2-0.20240108170749-ec883029c8e6 // indirect + github.com/charmbracelet/bubbles v0.17.2-0.20240125161725-fc18779a6ae9 // indirect github.com/charmbracelet/bubbletea v0.25.0 // indirect github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect github.com/dlclark/regexp2 v1.10.0 // indirect diff --git a/go.sum b/go.sum index 9b17f6f..4cc6591 100644 --- a/go.sum +++ b/go.sum @@ -14,8 +14,8 @@ github.com/beevik/etree v1.3.0 h1:hQTc+pylzIKDb23yYprodCWWTt+ojFfUZyzU09a/hmU= github.com/beevik/etree v1.3.0/go.mod h1:aiPf89g/1k3AShMVAzriilpcE4R/Vuor90y83zVZWFc= github.com/catppuccin/go v0.2.0 h1:ktBeIrIP42b/8FGiScP9sgrWOss3lw0Z5SktRoithGA= github.com/catppuccin/go v0.2.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc= -github.com/charmbracelet/bubbles v0.17.2-0.20240108170749-ec883029c8e6 h1:6nVCV8pqGaeyxetur3gpX3AAaiyKgzjIoCPV3NXKZBE= -github.com/charmbracelet/bubbles v0.17.2-0.20240108170749-ec883029c8e6/go.mod h1:9HxZWlkCqz2PRwsCbYl7a3KXvGzFaDHpYbSYMJ+nE3o= +github.com/charmbracelet/bubbles v0.17.2-0.20240125161725-fc18779a6ae9 h1:DgM7KYTYQqfv7FmUFsSMgjpzsQgZPToBKANhrbgEGmg= +github.com/charmbracelet/bubbles v0.17.2-0.20240125161725-fc18779a6ae9/go.mod h1:bFPs/pcBrPDNRHK9DOOctOwvdSjRtdA5iFmhdQ/QT7w= github.com/charmbracelet/bubbletea v0.25.0 h1:bAfwk7jRz7FKFl9RzlIULPkStffg5k6pNt5dywy4TcM= github.com/charmbracelet/bubbletea v0.25.0/go.mod h1:EN3QDR1T5ZdWmdfDzYcqOCAps45+QIJbLOBxmVNWNNg= github.com/charmbracelet/lipgloss v0.9.1 h1:PNyd3jvaJbg4jRHKWXnCj1akQm4rh8dbEzN1p/u1KWg= diff --git a/form.go b/interactive.go similarity index 97% rename from form.go rename to interactive.go index 2b87652..815fa62 100644 --- a/form.go +++ b/interactive.go @@ -181,6 +181,12 @@ func runForm(config *Config) (*Config, error) { Validate(validateInteger), ), ).WithTheme(theme).WithHeight(10) + + // Let's first select a input file if not specified + if config.Input == "" { + config.Input = pickFile() + } + err := f.Run() config.Padding = parsePadding(padding) @@ -260,3 +266,7 @@ func parsePadding(v string) []int { } var parseMargin = parsePadding + +func pickFile() string { + return "main.go" +}