9sh

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit c92b0536fa120e05c8305b243eebe1d69599ec86
parent 65f3ba42356d9800e3836fac79d544560f0cb784
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Sat,  9 Dec 2023 08:11:55 +0900

add ls

Diffstat:
Mmain.go | 15+++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/main.go b/main.go @@ -9,6 +9,7 @@ import ( "log" "net" "os" + "path" "strings" "git.mtkn.jp/lib9p" @@ -40,16 +41,26 @@ func (c *cmd) run(s *stat) error { if len(c.args) != 2 { return fmt.Errorf("usage: cd <dir>") } - f, err := s.fsys.Open(c.args[1]) + p := path.Join(s.cwd, c.args[1]) + f, err := s.fsys.Open(p) if err != nil { return err } s.f = f - s.cwd = c.args[1] + s.cwd = p return nil case "pwd": fmt.Println(s.cwd) return nil + case "ls": + files, err := fs.Glob(s.fsys, s.cwd + "/*") + if err != nil { + return err + } + for _, f := range files { + fmt.Println(f) + } + return nil default: return fmt.Errorf("unknown command %v", c.args[0]) }