Skip to content

Commit

Permalink
update help message
Browse files Browse the repository at this point in the history
  • Loading branch information
shenwei356 committed Nov 24, 2022
1 parent 79bc8c3 commit 9f1c122
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 47 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ Examples:
More examples: https://github.com/shenwei356/brename
Flags:
--clear remove all .brename_detail.txt" file, you may need to add -R/--recursive to recursivel clear all files in given path
--clear remove all .brename_detail.txt" file, you may need to add -R/--recursive to recursively clear all files in the given path
-x, --disable-undo do not create .brename_detail.txt file for undo
-d, --dry-run print rename operations but do not run
-F, --exclude-filters strings exclude file filter(s) (regular expression, NOT wildcard). multiple values supported, e.g., -F ".html" -F ".htm", but ATTENTION: comma in filter is treated as separator of multiple filters
Expand Down
31 changes: 15 additions & 16 deletions brename.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,9 @@ func init() {
RootCmd.Flags().BoolP("ignore-case", "i", false, "ignore case of -p/--pattern, -f/--include-filters and -F/--exclude-filters")
RootCmd.Flags().BoolP("ignore-ext", "e", false, "ignore file extension. i.e., replacement does not change file extension")

RootCmd.Flags().StringSliceP("include-filters", "f", []string{"."}, `include file filter(s) (regular expression, NOT wildcard). multiple values supported, e.g., -f ".html" -f ".htm", but ATTENTION: comma in filter is treated as separator of multiple filters`)
RootCmd.Flags().StringSliceP("skip-filters", "S", []string{`^\.`}, `skip file filter(s) (regular expression, NOT wildcard). multiple values supported, e.g., -S "^\." for skipping files starting with a dot, but ATTENTION: comma in filter is treated as separator of multiple filters`)
RootCmd.Flags().StringSliceP("exclude-filters", "F", []string{}, `exclude file filter(s) (regular expression, NOT wildcard). multiple values supported, e.g., -F ".html" -F ".htm", but ATTENTION: comma in filter is treated as separator of multiple filters`)
RootCmd.Flags().StringSliceP("include-filters", "f", []string{"."}, `include file filter(s) (regular expression, NOT wildcard). multiple values supported, e.g., -f ".html" -f ".htm", but ATTENTION: each comma in the filter is treated as the separator of multiple filters, please use double quotation marks for patterns containing comma, e.g., -p '"A{2,}"'`)
RootCmd.Flags().StringSliceP("skip-filters", "S", []string{`^\.`}, `skip file filter(s) (regular expression, NOT wildcard). multiple values supported, e.g., -S "^\." for skipping files starting with a dot, but ATTENTION: each comma in the filter is treated as the separator of multiple filters, please use double quotation marks for patterns containing comma, e.g., -p '"A{2,}"`)
RootCmd.Flags().StringSliceP("exclude-filters", "F", []string{}, `exclude file filter(s) (regular expression, NOT wildcard). multiple values supported, e.g., -F ".html" -F ".htm", but ATTENTION: each comma in the filter is treated as the separator of multiple filters, please use double quotation marks for patterns containing comma, e.g., -p '"A{2,}"`)

RootCmd.Flags().BoolP("list", "l", false, `only list paths that match pattern`)
RootCmd.Flags().StringP("list-sep", "s", "\n", `separator for list of found paths`)
Expand All @@ -410,7 +410,7 @@ func init() {
RootCmd.Flags().BoolP("undo", "u", false, "undo the LAST successful operation")
RootCmd.Flags().BoolP("force-undo", "U", false, "continue undo even when some operations failed")
RootCmd.Flags().BoolP("disable-undo", "x", false, "do not create .brename_detail.txt file for undo")
RootCmd.Flags().BoolP("clear", "", false, `remove all .brename_detail.txt" file, you may need to add -R/--recursive to recursivel clear all files in given path`)
RootCmd.Flags().BoolP("clear", "", false, `remove all .brename_detail.txt" file, you may need to add -R/--recursive to recursively clear all files in the given path`)

RootCmd.Example = ` 1. dry run and showing potential dangerous operations
brename -p "abc" -d
Expand Down Expand Up @@ -443,29 +443,28 @@ func init() {
More examples: https://github.com/shenwei356/brename`

RootCmd.SetUsageTemplate(`Usage:{{if .Runnable}}
{{if .HasAvailableFlags}}{{appendIfNotPresent .UseLine "[path ...]"}}{{else}}{{.UseLine}}{{end}}{{end}}{{if .HasAvailableSubCommands}}
{{ .CommandPath}} [command]{{end}} {{if gt .Aliases 0}}
{{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
{{.CommandPath}} [command]{{end}} {{if gt (len .Aliases) 0}}
Aliases:
{{.NameAndAliases}}
{{end}}{{if .HasExample}}
{{.NameAndAliases}}{{end}}{{if .HasExample}}
Examples:
{{ .Example }}{{end}}{{ if .HasAvailableSubCommands}}
{{.Example}}{{end}}{{if .HasAvailableSubCommands}}
Available Commands:{{range .Commands}}{{if .IsAvailableCommand}}
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{ if .HasAvailableLocalFlags}}
Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}
Flags:
{{.LocalFlags.FlagUsages | trimRightSpace}}{{end}}{{ if .HasAvailableInheritedFlags}}
{{.LocalFlags.FlagUsagesWrapped 110 | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}
Global Flags:
{{.InheritedFlags.FlagUsages | trimRightSpace}}{{end}}{{if .HasHelpSubCommands}}
{{.InheritedFlags.FlagUsagesWrapped 110 | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}}
Additional help topics:{{range .Commands}}{{if .IsHelpCommand}}
{{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{ if .HasAvailableSubCommands }}
Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
{{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}}
Use "{{.CommandPath}} --help" for more information about a command.{{end}}
Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}}
`)

pathTree = make(map[string]struct{}, 1000)
Expand Down
24 changes: 13 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,24 @@ module github.com/shenwei356/brename
go 1.17

require (
github.com/fatih/color v1.12.0
github.com/mattn/go-colorable v0.1.8
github.com/shenwei356/breader v0.2.0
github.com/fatih/color v1.13.0
github.com/mattn/go-colorable v0.1.13
github.com/shenwei356/breader v0.3.2
github.com/shenwei356/go-logging v0.0.0-20171012171522-c6b9702d88ba
github.com/shenwei356/natsort v0.0.0-20190418160752-600d539c017d
github.com/shenwei356/util v0.3.0
github.com/spf13/cobra v1.2.1
github.com/shenwei356/natsort v0.0.0-20220117010048-580176ad49fb
github.com/shenwei356/util v0.5.0
github.com/spf13/cobra v1.6.1
)

require (
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/klauspost/compress v1.11.4 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/klauspost/compress v1.15.1 // indirect
github.com/klauspost/pgzip v1.2.5 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/shenwei356/xopen v0.0.0-20181203091311-f4f16ddd3992 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/shenwei356/xopen v0.2.2 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/twotwotwo/sorts v0.0.0-20160814051341-bf5c1f2b8553 // indirect
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
)
Loading

0 comments on commit 9f1c122

Please sign in to comment.