Support multiple file/directory arguments for all commands

- Change sum add, sum update, check, and clear to accept 1+ paths
- Update README usage examples to show multiple path support
- Add TODO section with planned future improvements
This commit is contained in:
2026-02-01 03:21:36 -08:00
parent 9ad48fb9b0
commit c856ea25be
2 changed files with 61 additions and 18 deletions

View File

@@ -62,17 +62,31 @@ func newSumCmd() *cobra.Command {
}
add := &cobra.Command{
Use: "add <dir>",
Use: "add <path>...",
Short: "Write checksums for files missing them",
Args: cobra.ExactArgs(1),
RunE: func(_ *cobra.Command, a []string) error { return ProcessSumAdd(a[0]) },
Args: cobra.MinimumNArgs(1),
RunE: func(_ *cobra.Command, a []string) error {
for _, p := range a {
if err := ProcessSumAdd(p); err != nil {
return err
}
}
return nil
},
}
upd := &cobra.Command{
Use: "update <dir>",
Use: "update <path>...",
Short: "Recalculate checksum when file newer than stored sumtime",
Args: cobra.ExactArgs(1),
RunE: func(_ *cobra.Command, a []string) error { return ProcessSumUpdate(a[0]) },
Args: cobra.MinimumNArgs(1),
RunE: func(_ *cobra.Command, a []string) error {
for _, p := range a {
if err := ProcessSumUpdate(p); err != nil {
return err
}
}
return nil
},
}
cmd.AddCommand(add, upd)
@@ -129,10 +143,17 @@ func readSumTime(path string) (time.Time, error) {
func newClearCmd() *cobra.Command {
return &cobra.Command{
Use: "clear <dir>",
Use: "clear <path>...",
Short: "Remove checksum xattrs from tree",
Args: cobra.ExactArgs(1),
RunE: func(_ *cobra.Command, a []string) error { return ProcessClear(a[0]) },
Args: cobra.MinimumNArgs(1),
RunE: func(_ *cobra.Command, a []string) error {
for _, p := range a {
if err := ProcessClear(p); err != nil {
return err
}
}
return nil
},
}
}
@@ -164,10 +185,17 @@ func ProcessClear(dir string) error {
func newCheckCmd() *cobra.Command {
var cont bool
cmd := &cobra.Command{
Use: "check <dir>",
Use: "check <path>...",
Short: "Verify stored checksums",
Args: cobra.ExactArgs(1),
RunE: func(_ *cobra.Command, a []string) error { return ProcessCheck(a[0], cont) },
Args: cobra.MinimumNArgs(1),
RunE: func(_ *cobra.Command, a []string) error {
for _, p := range a {
if err := ProcessCheck(p, cont); err != nil {
return err
}
}
return nil
},
}
cmd.Flags().BoolVar(&cont, "continue", false, "continue after errors and report each file")
return cmd