Spaces:
Runtime error
Runtime error
File size: 658 Bytes
98f8e86 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
package cmd
import (
"context"
"fmt"
"github.com/spf13/cobra"
"llm-cli/internal/client"
)
func newLsCmd() *cobra.Command {
return &cobra.Command{
Use: "ls [path]",
Short: "List directory contents in the VM",
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
path := "/data"
if len(args) == 1 {
path = args[0]
}
c := client.New(server)
entries, err := c.ListDir(context.Background(), user, path)
if err != nil {
return err
}
for _, e := range entries {
if e.IsDir {
fmt.Println(e.Name + "/")
} else {
fmt.Println(e.Name)
}
}
return nil
},
}
}
|