mirror of
https://github.com/charmbracelet/glow.git
synced 2026-08-09 09:49:09 +02:00
fix: fallback to the current directory if no argument was given
This commit is contained in:
parent
2671509003
commit
e44e4684e1
1 changed files with 8 additions and 4 deletions
12
ui/ui.go
12
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(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue