Skip to content

Commit

Permalink
fix: file remove permission on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
beetcb committed Feb 11, 2022
1 parent 85a5a4d commit e07a2ed
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dl.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ func (dl GHReleaseDl) ExtractBinary() error {
if err != nil {
return err
}
defer openfile.Close()

fileExt := filepath.Ext(dl.Url)
var decompressedBinary io.Reader
Expand Down Expand Up @@ -121,6 +120,7 @@ func (dl GHReleaseDl) ExtractBinary() error {
return fmt.Errorf("unsupported file format: %v", fileExt)
}
defer os.Remove(tmpfileName)
defer openfile.Close()
out, err := os.Create(dl.BinaryName)
if err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions ghdl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"os"
"path/filepath"
"strings"

"github.com/beetcb/ghdl"
Expand Down Expand Up @@ -38,6 +39,7 @@ ghdl handles archived or compressed file as well`,
if binaryNameFlag != "" {
ghReleaseDl.BinaryName = binaryNameFlag
}
h.Print(fmt.Sprintf("start downloading [%s]", filepath.Base(ghReleaseDl.Url)), h.PrintModeInfo)
if err := ghReleaseDl.DlTo(pathFlag); err != nil {
h.Print(fmt.Sprintf("download failed: %s", err), h.PrintModeErr)
os.Exit(1)
Expand Down
2 changes: 1 addition & 1 deletion helper/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (
)

func Sprint(str string, printMode int) string {
printWidth := 60
printWidth := 80
var newStyle = lipgloss.NewStyle().Width(printWidth)
prompt := lipgloss.NewStyle().Foreground(lipgloss.Color("13")).Render("→ ")
var sPrint string = prompt
Expand Down
6 changes: 1 addition & 5 deletions helper/sl/sl.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"github.com/charmbracelet/lipgloss"
)

const maxWidth = 80

type model struct {
choices []string // items on the to-do list
cursor int // which to-do list item our cursor is pointing at
Expand Down Expand Up @@ -55,9 +53,8 @@ func (m model) View() string {
paddingS := lipgloss.NewStyle().PaddingLeft(2).Width(printWidth)
colorS := paddingS.Copy().
Foreground(blue).BorderLeft(true).BorderForeground(blue)
s := "\n" + h.Sprint("there is more than one option after filtering, please select it manually", h.PrintModeInfo) + "\n"
s := h.Sprint("there is more than one option after filtering, please select it manually", h.PrintModeInfo) + "\n"
if m.selected == -1 {
s += "\n"
for i, choice := range m.choices {
if m.cursor == i {
s += colorS.Render(choice) + "\n"
Expand All @@ -68,7 +65,6 @@ func (m model) View() string {
// Send the UI for rendering
return s + "\n"
} else {
s += h.Sprint(fmt.Sprintf("start downloading %s", lipgloss.NewStyle().Foreground(blue).Render(m.choices[m.selected])), h.PrintModeInfo) + "\n"
return s
}
}
Expand Down

0 comments on commit e07a2ed

Please sign in to comment.