feat(font): support URL's

resolves #2400
This commit is contained in:
Jan De Dobbeleer 2022-06-10 14:05:27 +02:00 committed by Jan De Dobbeleer
parent 0dbe5f2aa4
commit ad12ad8ed2

View file

@ -4,6 +4,7 @@ import (
"fmt"
"io"
"os"
"strings"
"github.com/charmbracelet/bubbles/list"
"github.com/charmbracelet/bubbles/spinner"
@ -124,9 +125,11 @@ func installFontZIP(zipFile []byte) {
func (m *main) Init() tea.Cmd {
if len(m.fontname) != 0 {
m.state = downloadFont
url := fmt.Sprintf("https://github.com/ryanoasis/nerd-fonts/releases/latest/download/%s.zip", m.fontname)
if !strings.HasPrefix(m.fontname, "https") {
m.fontname = fmt.Sprintf("https://github.com/ryanoasis/nerd-fonts/releases/latest/download/%s.zip", m.fontname)
}
defer func() {
go downloadFontZip(url)
go downloadFontZip(m.fontname)
}()
m.spinner.Spinner = spinner.Globe
return m.spinner.Tick