feat: implement list
This commit is contained in:
23
main.go
23
main.go
@@ -113,6 +113,26 @@ func Switch(ctx context.Context, cmd *cli.Command) error {
|
||||
return os.Symlink(worktree, cwd)
|
||||
}
|
||||
|
||||
func List(ctx context.Context, cmd *cli.Command) error {
|
||||
wtd, err := Getwtd()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
project, err := os.Getwd()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dirs, err := os.ReadDir(filepath.Join(wtd, filepath.Base(project)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for i := range dirs {
|
||||
fmt.Println(dirs[i].Name())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
cmd := cli.Command{
|
||||
Name: "wt",
|
||||
@@ -125,7 +145,8 @@ func main() {
|
||||
Name: "clone",
|
||||
},
|
||||
{
|
||||
Name: "list",
|
||||
Name: "list",
|
||||
Action: List,
|
||||
},
|
||||
{
|
||||
Name: "switch",
|
||||
|
||||
Reference in New Issue
Block a user