Skip to content
This repository was archived by the owner on Jul 2, 2024. It is now read-only.

Commit de4d02a

Browse files
committed
add missing file
1 parent d774eae commit de4d02a

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

shell/refresh.go

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package shell
2+
3+
import (
4+
"errors"
5+
6+
"github.com/abiosoft/ishell"
7+
)
8+
9+
func refreshCmd(ctx *ShellCtxt) *ishell.Cmd {
10+
return &ishell.Cmd{
11+
Name: "refresh",
12+
Help: "refreshes the tree with remote changes",
13+
Func: func(c *ishell.Context) {
14+
err := ctx.api.Refresh()
15+
if err != nil {
16+
c.Err(err)
17+
return
18+
}
19+
n, err := ctx.api.Filetree().NodeByPath(ctx.path, nil)
20+
if err != nil {
21+
c.Err(errors.New("current path is invalid"))
22+
23+
ctx.node = ctx.api.Filetree().Root()
24+
ctx.path = ctx.node.Name()
25+
c.SetPrompt(ctx.prompt())
26+
return
27+
}
28+
ctx.node = n
29+
},
30+
}
31+
}

0 commit comments

Comments
 (0)