Glob as variant of Arg Flag type : accepts multiple files, as shell-expanded. use in um sort and um cat

NOTE: um sort expects .md files, while um cat expects .um : .um filelists are concatted together, while .md lists are just lists
This commit is contained in:
bth 2026-07-15 17:20:09 -07:00
commit 5aac37f8a8
5 changed files with 74 additions and 22 deletions

View file

@ -19,15 +19,15 @@ const (
)
type options struct {
Source flags.String
Key flags.String
Write flags.Bool
Help flags.Bool
Filelist flags.Glob
Key flags.String
Write flags.Bool
Help flags.Bool
}
func initOpts() options {
return options{
flags.String{"--source", "-s", "", "path to source list. reads from stdin if omitted."},
flags.Glob{nil, ".md filelist. accepts multiple. reads from stdin if not provided"},
flags.String{"--key", "-k", "", "path to sort key"},
flags.Bool{"--write", "-w", false, "write sorted list back to --key file"},
flags.Bool{"--help", "-h", false, "show help"},
@ -84,7 +84,8 @@ func Sort(args []string) {
return
}
sslice, err := pipe.FileListSplitMaybeStdin(opts.Source.Val)
// NOTE: um sort expects a list of .md files, in contrast to um cat.
sslice, err := pipe.GlobOrStdin(opts.Filelist.Val)
if err != nil {
log.Fatalf("um %s: %s", CMD, err)
}