command.go
This file
Path
file/command.go
79 lines · 1.8 KiB · Go
Last changed by
chore: prepare v2 (#1116)Drew Smirnoffbefore adoption02d6f06
History of this fileTake it
The walk stopped after 200 commits: lines older than 6837ed2 point at it.
feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
lines 1–5why, one step back1package file23import (4 "errors"5 "fmt"refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
line 6why, one step back6 "os"feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
lines 7–8why, one step back7 "path/filepath"8chore: update to bubbletea v2 (#1112)Drew Smirnoffbefore adoptionf6dd28e
lines 9–11why, one step back9 "charm.land/bubbles/v2/filepicker"10 "charm.land/bubbles/v2/help"11 tea "charm.land/bubbletea/v2"chore: prepare v2 (#1116)Drew Smirnoffbefore adoption02d6f06
lines 12–13why, one step back12 "charm.land/gum/v2/internal/timeout"13 "charm.land/gum/v2/style"feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
lines 14–30why, one step back14)1516// Run is the interface to picking a file.17func (o Options) Run() error {18 if !o.File && !o.Directory {19 return errors.New("at least one between --file and --directory must be set")20 }2122 if o.Path == "" {23 o.Path = "."24 }2526 path, err := filepath.Abs(o.Path)27 if err != nil {28 return fmt.Errorf("file not found: %w", err)29 }30refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
lines 31–33why, one step back31 fp := filepicker.New()32 fp.CurrentDirectory = path33 fp.Path = pathfix: lint issues (#909)Carlos Alexandro Beckerbefore adoption817c4bd
line 34why, one step back34 fp.SetHeight(o.Height)refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
lines 35–49why, one step back35 fp.AutoHeight = o.Height == 036 fp.Cursor = o.Cursor37 fp.DirAllowed = o.Directory38 fp.FileAllowed = o.File39 fp.ShowPermissions = o.Permissions40 fp.ShowSize = o.Size41 fp.ShowHidden = o.All42 fp.Styles = filepicker.DefaultStyles()43 fp.Styles.Cursor = o.CursorStyle.ToLipgloss()44 fp.Styles.Symlink = o.SymlinkStyle.ToLipgloss()45 fp.Styles.Directory = o.DirectoryStyle.ToLipgloss()46 fp.Styles.File = o.FileStyle.ToLipgloss()47 fp.Styles.Permission = o.PermissionsStyle.ToLipgloss()48 fp.Styles.Selected = o.SelectedStyle.ToLipgloss()49 fp.Styles.FileSize = o.FileSizeStyle.ToLipgloss()feat: adding --padding to most commands (#960)Carlos Alexandro Beckerbefore adoption6045525
line 50why, one step back50 top, right, bottom, left := style.ParsePadding(o.Padding)refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
line 51why, one step back51 m := model{feat(file): add --header (#768)Carlos Alexandro Beckerbefore adoptionf921ebd
line 52why, one step back52 filepicker: fp,feat: adding --padding to most commands (#960)Carlos Alexandro Beckerbefore adoption6045525
line 53why, one step back53 padding: []int{top, right, bottom, left},feat(file): add --header (#768)Carlos Alexandro Beckerbefore adoptionf921ebd
lines 54–58why, one step back54 showHelp: o.ShowHelp,55 help: help.New(),56 keymap: defaultKeymap(),57 headerStyle: o.HeaderStyle.ToLipgloss(),58 header: o.Header,refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
line 59why, one step back59 }feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
line 60why, one step back60feat: handle interrupts and timeouts (#747)Carlos Alexandro Beckerbefore adoption4f46952
lines 61–64why, one step back61 ctx, cancel := timeout.Context(o.Timeout)62 defer cancel()6364 tm, err := tea.NewProgram(chore: update to bubbletea v2 (#1112)Drew Smirnoffbefore adoptionf6dd28e
line 65why, one step back65 m,feat: handle interrupts and timeouts (#747)Carlos Alexandro Beckerbefore adoption4f46952
lines 66–68why, one step back66 tea.WithOutput(os.Stderr),67 tea.WithContext(ctx),68 ).Run()feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
line 69why, one step back69 if err != nil {refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
line 70why, one step back70 return fmt.Errorf("unable to pick selection: %w", err)feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
line 71why, one step back71 }refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e
lines 72–77why, one step back72 m = tm.(model)73 if m.selectedPath == "" {74 return errors.New("no file selected")75 }7677 fmt.Println(m.selectedPath)feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
lines 78–79why, one step back78 return nil79}