Skip to content
Myr

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 file

Take 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 back
1package file
23import (4 "errors"5 "fmt"

refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e

line 6why, one step back
6 "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 back
7 "path/filepath"
8

chore: update to bubbletea v2 (#1112)Drew Smirnoffbefore adoptionf6dd28e

lines 9–11why, one step back
9 "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 back
12 "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 back
14)
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 }30

refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e

lines 31–33why, one step back
31 fp := filepicker.New()
32 fp.CurrentDirectory = path33 fp.Path = path

fix: lint issues (#909)Carlos Alexandro Beckerbefore adoption817c4bd

line 34why, one step back
34 fp.SetHeight(o.Height)

refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e

lines 35–49why, one step back
35 fp.AutoHeight = o.Height == 0
36 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 back
50 top, right, bottom, left := style.ParsePadding(o.Padding)

refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e

line 51why, one step back
51 m := model{

feat(file): add --header (#768)Carlos Alexandro Beckerbefore adoptionf921ebd

line 52why, one step back
52 filepicker: fp,

feat: adding --padding to most commands (#960)Carlos Alexandro Beckerbefore adoption6045525

line 53why, one step back
53 padding: []int{top, right, bottom, left},

feat(file): add --header (#768)Carlos Alexandro Beckerbefore adoptionf921ebd

lines 54–58why, one step back
54 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 back
59 }

feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2

line 60why, one step back
60

feat: handle interrupts and timeouts (#747)Carlos Alexandro Beckerbefore adoption4f46952

lines 61–64why, one step back
61 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 back
65 m,

feat: handle interrupts and timeouts (#747)Carlos Alexandro Beckerbefore adoption4f46952

lines 66–68why, one step back
66 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 back
69 if err != nil {

refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e

line 70why, one step back
70 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 back
71 }

refactor: removing huh as a dep (#742)Carlos Alexandro Beckerbefore adoptione30fc5e

lines 72–77why, one step back
72 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 back
78 return nil
79}