From e44e4684e1421f0aebe4e2db3e9bf93d652e7793 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Thu, 6 Feb 2025 11:14:36 -0300 Subject: [PATCH] fix: fallback to the current directory if no argument was given --- ui/ui.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ui/ui.go b/ui/ui.go index 874a15e..dbc6fd7 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -151,9 +151,13 @@ func newModel(cfg Config) tea.Model { stash: newStashModel(&common), } - info, err := os.Stat(cfg.Path) + path := cfg.Path + if path == "" { + path = "." + } + info, err := os.Stat(path) if err != nil { - log.Error("unable to stat file", "file", m.common.cfg.Path, "error", err) + log.Error("unable to stat file", "file", path, "error", err) m.fatalErr = err return m } @@ -163,8 +167,8 @@ func newModel(cfg Config) tea.Model { cwd, _ := os.Getwd() m.state = stateShowDocument m.pager.currentDocument = markdown{ - localPath: cfg.Path, - Note: stripAbsolutePath(cfg.Path, cwd), + localPath: path, + Note: stripAbsolutePath(path, cwd), Modtime: info.ModTime(), } }