Skip to content

Commit

Permalink
refactor: ui tweak and freebsd support
Browse files Browse the repository at this point in the history
  • Loading branch information
abhimanyu003 committed Oct 11, 2024
1 parent 7ce4311 commit 6b7e63c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
23 changes: 17 additions & 6 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ before:
builds:
- main: ./main.go
binary: sttr
goos: ["linux", "darwin", "windows"]
goos: ["linux", "darwin", "windows", "freebsd"]
goarch: ["386", "amd64", "arm64"]
flags:
- -trimpath
ldflags:
- -s -w -X "main.version={{.Version}}"
env:
Expand Down Expand Up @@ -64,6 +66,7 @@ nfpms:
formats:
- deb
- rpm
- archlinux
- termux.deb
bindir: /usr/bin

Expand All @@ -77,7 +80,6 @@ snapcrafts:
confinement: strict
license: MIT
base: core20

apps:
sttr:
plugs: ["home", "network"]
Expand Down Expand Up @@ -201,7 +203,16 @@ docker_signs:
- --yes

archives:
- id: default
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
Expand All @@ -218,7 +229,7 @@ winget:
homepage: https://github.com/abhimanyu003/sttr
license_url: https://github.com/abhimanyu003/sttr/blob/master/LICENSE
copyright: Copyright (c) 2021-{{ .Now.Format "2006" }} Abhimanyu Sharma
release_notes: '{{ .Changelog }}'
release_notes: "{{ .Changelog }}"
release_notes_url: https://github.com/abhimanyu003/sttr/releases/tag/{{ .Tag }}
tags:
- cli
Expand All @@ -234,10 +245,10 @@ winget:
owner: abhimanyu003
name: winget-pkgs
branch: sttr-{{ .Version }}
token: '{{ .Env.GITHUB_TOKEN }}'
token: "{{ .Env.GITHUB_TOKEN }}"
pull_request:
enabled: true
base:
owner: microsoft
name: winget-pkgs
branch: master
branch: master
13 changes: 7 additions & 6 deletions ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package ui

import (
"fmt"
"golang.org/x/term"
"log"
"os"

"golang.org/x/term"

"github.com/abhimanyu003/sttr/processors"

"github.com/abhimanyu003/sttr/utils"
Expand Down Expand Up @@ -40,12 +41,12 @@ func (u *UI) Render() {
termWidth = maxWidth
}
if u.input == "" {
divider := lipgloss.NewStyle().Padding(0, 1).Foreground(borderStyle).Render("•")
divider := lipgloss.NewStyle().Margin(0, 1).Foreground(borderStyle).Render("•")
info := lipgloss.NewStyle().Foreground(specialStyle).Render("[ Enter 2 empty lines to process ]")

title := lipgloss.NewStyle().
MaxWidth(termWidth).
BorderStyle(lipgloss.DoubleBorder()).
BorderStyle(lipgloss.NormalBorder()).
BorderTop(true).
BorderBottom(true).
BorderForeground(borderStyle).
Expand All @@ -58,7 +59,7 @@ func (u *UI) Render() {
u.list = list.New(processors.List, list.NewDefaultDelegate(), 0, 0)
u.list.Title = "Select transformation"

if _, err := tea.NewProgram(u).Run(); err != nil {
if _, err := tea.NewProgram(u, tea.WithAltScreen()).Run(); err != nil {
log.Fatalf("error running ui: %v", err)
}

Expand All @@ -71,7 +72,7 @@ func (u *UI) Render() {
border := lipgloss.NewStyle().
Width(termWidth).
BorderTop(true).
BorderStyle(lipgloss.DoubleBorder()).
BorderStyle(lipgloss.NormalBorder()).
BorderForeground(borderStyle).String()

fmt.Println(border)
Expand All @@ -88,7 +89,7 @@ func (u *UI) View() string {
return ""
}

return appStyle.Margin(1, 1).Render(u.list.View())
return appStyle.Render(u.list.View())
}

func (u *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
Expand Down

0 comments on commit 6b7e63c

Please sign in to comment.