mirror of
https://github.com/charmbracelet/crush.git
synced 2025-08-02 05:20:46 +03:00
fix: start filepicker in cwd instead of os.Homedir
This commit is contained in:
@@ -92,6 +92,11 @@ func New(ctx context.Context, conn *sql.DB, cfg *config.Config) (*App, error) {
|
||||
return app, nil
|
||||
}
|
||||
|
||||
// Config returns the application configuration.
|
||||
func (app *App) Config() *config.Config {
|
||||
return app.config
|
||||
}
|
||||
|
||||
// RunNonInteractive handles the execution flow when a prompt is provided via CLI flag.
|
||||
func (app *App) RunNonInteractive(ctx context.Context, prompt string, quiet bool) error {
|
||||
slog.Info("Running in non-interactive mode")
|
||||
|
||||
@@ -45,11 +45,22 @@ type model struct {
|
||||
help help.Model
|
||||
}
|
||||
|
||||
func NewFilePickerCmp() FilePicker {
|
||||
func NewFilePickerCmp(workingDir string) FilePicker {
|
||||
t := styles.CurrentTheme()
|
||||
fp := filepicker.New()
|
||||
fp.AllowedTypes = []string{".jpg", ".jpeg", ".png"}
|
||||
fp.CurrentDirectory, _ = os.UserHomeDir()
|
||||
|
||||
if workingDir != "" {
|
||||
fp.CurrentDirectory = workingDir
|
||||
} else {
|
||||
// Fallback to current working directory, then home directory
|
||||
if cwd, err := os.Getwd(); err == nil {
|
||||
fp.CurrentDirectory = cwd
|
||||
} else {
|
||||
fp.CurrentDirectory, _ = os.UserHomeDir()
|
||||
}
|
||||
}
|
||||
|
||||
fp.ShowPermissions = false
|
||||
fp.ShowSize = false
|
||||
fp.AutoHeight = false
|
||||
|
||||
@@ -204,7 +204,7 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
return a, util.CmdHandler(dialogs.CloseDialogMsg{})
|
||||
}
|
||||
return a, util.CmdHandler(dialogs.OpenDialogMsg{
|
||||
Model: filepicker.NewFilePickerCmp(),
|
||||
Model: filepicker.NewFilePickerCmp(a.app.Config().WorkingDir()),
|
||||
})
|
||||
// Permissions
|
||||
case pubsub.Event[permission.PermissionRequest]:
|
||||
|
||||
Reference in New Issue
Block a user