(cmd *cobra.Command, args []string)
| 492 | } |
| 493 | |
| 494 | func fileListRun(cmd *cobra.Command, args []string) error { |
| 495 | longForm, _ := cmd.Flags().GetBool("long") |
| 496 | onePerLine, _ := cmd.Flags().GetBool("one") |
| 497 | |
| 498 | // Check if we're in a pipe |
| 499 | stat, _ := os.Stdout.Stat() |
| 500 | isPipe := (stat.Mode() & os.ModeCharDevice) == 0 |
| 501 | if isPipe { |
| 502 | onePerLine = true |
| 503 | } |
| 504 | |
| 505 | if len(args) == 0 { |
| 506 | args = []string{"."} |
| 507 | } |
| 508 | |
| 509 | path, err := fixRelativePaths(args[0]) |
| 510 | if err != nil { |
| 511 | return err |
| 512 | } |
| 513 | |
| 514 | filesChan := wshclient.FileListStreamCommand(RpcClient, wshrpc.FileListData{Path: path, Opts: &wshrpc.FileListOpts{All: false}}, &wshrpc.RpcOpts{Timeout: 2000}) |
| 515 | // Drain the channel when done |
| 516 | defer utilfn.DrainChannelSafe(filesChan, "fileListRun") |
| 517 | if longForm { |
| 518 | return filePrintLong(filesChan) |
| 519 | } |
| 520 | |
| 521 | if onePerLine { |
| 522 | for respUnion := range filesChan { |
| 523 | if respUnion.Error != nil { |
| 524 | log.Printf("error: %v", respUnion.Error) |
| 525 | return respUnion.Error |
| 526 | } |
| 527 | for _, f := range respUnion.Response.FileInfo { |
| 528 | fmt.Fprintln(os.Stdout, f.Name) |
| 529 | } |
| 530 | } |
| 531 | return nil |
| 532 | } |
| 533 | |
| 534 | return filePrintColumns(filesChan) |
| 535 | } |
nothing calls this directly
no test coverage detected