help: global flags help command now takes glob filter

This commit is contained in:
albertony 2023-11-03 20:46:39 +01:00 committed by Nick Craig-Wood
parent 731947f3ca
commit c6352231e4

View file

@ -12,6 +12,7 @@ import (
"github.com/rclone/rclone/fs" "github.com/rclone/rclone/fs"
"github.com/rclone/rclone/fs/config/configflags" "github.com/rclone/rclone/fs/config/configflags"
"github.com/rclone/rclone/fs/config/flags" "github.com/rclone/rclone/fs/config/flags"
"github.com/rclone/rclone/fs/filter"
"github.com/rclone/rclone/fs/filter/filterflags" "github.com/rclone/rclone/fs/filter/filterflags"
"github.com/rclone/rclone/fs/log/logflags" "github.com/rclone/rclone/fs/log/logflags"
"github.com/rclone/rclone/fs/rc/rcflags" "github.com/rclone/rclone/fs/rc/rcflags"
@ -62,14 +63,15 @@ var flagsRe *regexp.Regexp
// Show the flags // Show the flags
var helpFlags = &cobra.Command{ var helpFlags = &cobra.Command{
Use: "flags [<regexp to match>]", Use: "flags [<filter>]",
Short: "Show the global flags for rclone", Short: "Show the global flags for rclone",
Run: func(command *cobra.Command, args []string) { Run: func(command *cobra.Command, args []string) {
if len(args) > 0 { if len(args) > 0 {
re, err := regexp.Compile(`(?i)` + args[0]) re, err := filter.GlobStringToRegexp(args[0], false)
if err != nil { if err != nil {
log.Fatalf("Failed to compile flags regexp: %v", err) log.Fatalf("Failed to compile flags regexp: %v", err)
} }
fs.Debugf(nil, "Flags filter: %s", re.String())
flagsRe = re flagsRe = re
} }
if GeneratingDocs { if GeneratingDocs {