diff --git a/go.mod b/go.mod index 8f6fadb..8195393 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,9 @@ require ( ) require ( + github.com/atotto/clipboard v0.1.4 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect + github.com/charmbracelet/bubbles v0.21.0 // indirect github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect github.com/charmbracelet/x/ansi v0.10.1 // indirect github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect diff --git a/go.sum b/go.sum index dacd7fc..0ac39b0 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,9 @@ +github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= +github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= +github.com/charmbracelet/bubbles v0.21.0 h1:9TdC97SdRVg/1aaXNVWfFH3nnLAwOXr8Fn6u6mfQdFs= +github.com/charmbracelet/bubbles v0.21.0/go.mod h1:HF+v6QUR4HkEpz62dx7ym2xc71/KBHg+zKwJtMw+qtg= github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlvF9nRvCICw= github.com/charmbracelet/bubbletea v1.3.10/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4= github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs= diff --git a/scale_picker.go b/scale_picker.go index 8918006..c8625bd 100644 --- a/scale_picker.go +++ b/scale_picker.go @@ -2,19 +2,23 @@ package main import ( "fmt" + "strconv" "strings" + "github.com/charmbracelet/bubbles/textinput" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" ) type scalePickerModel struct { - scales []float32 - selected int - current float32 - monitor string - width uint32 - height uint32 + scales []float32 + selected int + current float32 + monitor string + width uint32 + height uint32 + customMode bool + customInput textinput.Model } var commonScales = []float32{ @@ -30,13 +34,20 @@ func newScalePicker(monitor string, currentScale float32, width, height uint32) } } + ti := textinput.New() + ti.Placeholder = "Enter scale (e.g., 1.5)" + ti.CharLimit = 10 + ti.Width = 20 + return scalePickerModel{ - scales: commonScales, - selected: selected, - current: currentScale, - monitor: monitor, - width: width, - height: height, + scales: commonScales, + selected: selected, + current: currentScale, + monitor: monitor, + width: width, + height: height, + customMode: false, + customInput: ti, } } @@ -51,12 +62,45 @@ func (m scalePickerModel) Init() tea.Cmd { } func (m scalePickerModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { + var cmd tea.Cmd + + // Handle custom input mode + if m.customMode { + switch msg := msg.(type) { + case tea.KeyMsg: + switch msg.String() { + case "esc": + m.customMode = false + m.customInput.SetValue("") + return m, nil + case "enter": + value := strings.TrimSpace(m.customInput.Value()) + if scale, err := strconv.ParseFloat(value, 32); err == nil && scale > 0 && scale <= 10 { + return m, func() tea.Msg { + return scaleSelectedMsg{scale: float32(scale)} + } + } + // Invalid input, stay in custom mode + return m, nil + } + } + m.customInput, cmd = m.customInput.Update(msg) + return m, cmd + } + + // Handle normal mode switch msg := msg.(type) { case tea.KeyMsg: switch msg.String() { case "q", "ctrl+c", "esc": return m, func() tea.Msg { return scaleCancelledMsg{} } + case "c": + // Enter custom mode + m.customMode = true + m.customInput.Focus() + return m, m.customInput.Cursor.BlinkCmd() + case "up", "k": if m.selected > 0 { m.selected-- @@ -116,6 +160,20 @@ func (m scalePickerModel) View() string { s.WriteString(titleStyle.Render(fmt.Sprintf("Select Scale for %s", m.monitor))) s.WriteString("\n\n") + // Custom input mode + if m.customMode { + customStyle := lipgloss.NewStyle(). + BorderStyle(lipgloss.RoundedBorder()). + BorderForeground(lipgloss.Color("62")). + Padding(1). + Width(40) + + s.WriteString(customStyle.Render( + fmt.Sprintf("Enter Custom Scale:\n\n%s\n\nValid range: 0.1 - 10.0\nPress Enter to confirm, Esc to cancel", m.customInput.View()), + )) + return s.String() + } + itemStyle := lipgloss.NewStyle(). PaddingLeft(2) @@ -177,7 +235,7 @@ func (m scalePickerModel) View() string { helpStyle := lipgloss.NewStyle(). Foreground(lipgloss.Color("241")) - help := "↑/↓: Navigate • Enter: Select • 1: 1.00x • 2: 2.00x • Esc: Cancel" + help := "↑/↓: Navigate • Enter: Select • c: Custom • 1: 1.00x • 2: 2.00x • Esc: Cancel" s.WriteString(helpStyle.Render(help)) // Add preview of what the scale means -- knotmirror 0.0.1 From 01e6b792a572d01795889e2d8de51881c3b62163 Mon Sep 17 00:00:00 2001 From: Eran Sandler Date: Mon, 22 Sep 2025 15:25:41 -0700 Subject: [PATCH 2/2] refactor: simplify release script workflow Streamlines the release process by removing manual GitHub release creation and relying on GitHub Actions automation for consistency. --- release.sh | 41 +++++------------------------------------ 1 file changed, 5 insertions(+), 36 deletions(-) diff --git a/release.sh b/release.sh index be399f1..1d467b7 100755 --- a/release.sh +++ b/release.sh @@ -63,9 +63,6 @@ generate_changelog() { local from_tag=$1 local to_ref=${2:-HEAD} - echo "## Analyzing changes since ${from_tag}..." - echo "" - # Check if npx is available if ! command -v npx &> /dev/null; then print_color $YELLOW "npx not found, falling back to git log" @@ -284,47 +281,19 @@ git push origin "$NEW_VERSION" # Clean up rm "$TEMP_NOTES" -# Create GitHub release if gh CLI is available +# GitHub Actions will automatically create the release echo "" print_color $BLUE "Tag created and pushed successfully!" - -if command -v gh &> /dev/null; then - print_color $BLUE "GitHub CLI detected. Creating release..." - - # Check if authenticated - if gh auth status &> /dev/null; then - # Create release with generated notes - if gh release create "$NEW_VERSION" --title "Release $NEW_VERSION" --notes "$RELEASE_NOTES"; then - print_color $GREEN "GitHub release created successfully!" - print_color $GREEN "View release at: $(gh repo view --web 2>/dev/null | grep -o 'https://[^[:space:]]*')/releases/tag/$NEW_VERSION" - else - print_color $YELLOW "Failed to create GitHub release. GitHub Actions will handle it automatically." - fi - else - print_color $YELLOW "GitHub CLI not authenticated. Please run 'gh auth login' for automatic release creation." - print_color $YELLOW "GitHub Actions will automatically create a release from this tag." - fi -else - print_color $YELLOW "GitHub CLI (gh) not found. GitHub Actions will automatically create a release from this tag." -fi +print_color $GREEN "GitHub Actions will automatically build binaries and create the release." echo "" print_color $GREEN "You can monitor the release at:" echo " https://github.com/$(git remote get-url origin | sed 's/.*github.com[:\/]\(.*\)\.git/\1/')/releases" echo "" -# Optionally trigger manual workflow -print_color $BLUE "Alternatively, you can trigger a manual release workflow." -read -p "Would you like instructions for manual release? (y/N): " -n 1 -r -echo -if [[ $REPLY =~ ^[Yy]$ ]]; then - echo "" - print_color $BLUE "To trigger manual release:" - echo "1. Go to: https://github.com/$(git remote get-url origin | sed 's/.*github.com[:\/]\(.*\)\.git/\1/')/actions/workflows/release.yml" - echo "2. Click 'Run workflow'" - echo "3. Enter version: ${NEW_VERSION}" - echo "4. Click 'Run workflow' button" -fi +# Monitor the automatic workflow +print_color $BLUE "The release workflow should start automatically." +echo "Monitor progress at: https://github.com/$(git remote get-url origin | sed 's/.*github.com[:\/]\(.*\)\.git/\1/')/actions" print_color $GREEN "" print_color $GREEN "Release ${NEW_VERSION} preparation complete! 🎉" \ No newline at end of file