| 53 | ) |
| 54 | |
| 55 | func rm(cmd *cobra.Command, args []string) error { |
| 56 | if len(args) < 1 { |
| 57 | return invalidArgumentsErrorWithDetails("rm: missing operand", argumentErrorDetails("path")) |
| 58 | } |
| 59 | |
| 60 | opts, err := parseRemoveOptions(cmd) |
| 61 | if err != nil { |
| 62 | return err |
| 63 | } |
| 64 | |
| 65 | dbx := filesNewFunc(config) |
| 66 | |
| 67 | targets, err := validateRemoveTargets(dbx, args, opts) |
| 68 | if err != nil { |
| 69 | return err |
| 70 | } |
| 71 | |
| 72 | results, err := removeTargets(dbx, targets, opts) |
| 73 | if err != nil { |
| 74 | return err |
| 75 | } |
| 76 | |
| 77 | return commandOutput(cmd).Render(func(w io.Writer) error { |
| 78 | if !opts.verbose { |
| 79 | return nil |
| 80 | } |
| 81 | return renderRemoveResults(w, results) |
| 82 | }, newJSONCommandOperationOutput(cmd, nil, removeOperationResults(results), nil)) |
| 83 | } |
| 84 | |
| 85 | func removeOperationResults(results []removeResult) []jsonOperationResult { |
| 86 | operationResults := make([]jsonOperationResult, 0, len(results)) |