mirror of
https://github.com/rclone/rclone.git
synced 2025-04-22 03:48:51 +08:00
convmv: update help text - FIXME WIP
need a help line for each conversion mode
This commit is contained in:
parent
d08543070a
commit
e14109e1b4
cmd/convmv
@ -167,7 +167,9 @@ var commandDefinition = &cobra.Command{
|
||||
Short: `Convert file and directory names`,
|
||||
// Warning! "|" will be replaced by backticks below
|
||||
Long: strings.ReplaceAll(`
|
||||
Docs todo!
|
||||
This command renames files and directory names according a user supplied conversion.
|
||||
|
||||
It is useful for renaming a lot of files in an automated way.
|
||||
|
||||
`+sprintList()+`
|
||||
|
||||
@ -459,27 +461,42 @@ func toASCII(s string) string {
|
||||
}
|
||||
|
||||
func sprintList() string {
|
||||
s := fmt.Sprintln("Conversion modes: ")
|
||||
var out strings.Builder
|
||||
|
||||
_, _ = out.WriteString(`### Conversion modes
|
||||
|
||||
The conversion mode |-t| or |--conv| flag must be specified. This
|
||||
defines what transformation the |convmv| command will make.
|
||||
|
||||
`)
|
||||
for _, v := range Opt.ConvertAlgo.Choices() {
|
||||
s += fmt.Sprintln(v + " ")
|
||||
_, _ = fmt.Fprintf(&out, "- `%s`\n", v)
|
||||
}
|
||||
s += fmt.Sprintln()
|
||||
_, _ = out.WriteRune('\n')
|
||||
|
||||
s += fmt.Sprintln("Char maps: ")
|
||||
_, _ = out.WriteString(`### Char maps
|
||||
|
||||
These are the choices for the |--charmap| flag.
|
||||
|
||||
`)
|
||||
for _, v := range Opt.CmapFlag.Choices() {
|
||||
s += fmt.Sprintln(v + " ")
|
||||
_, _ = fmt.Fprintf(&out, "- `%s`\n", v)
|
||||
}
|
||||
s += fmt.Sprintln()
|
||||
_, _ = out.WriteRune('\n')
|
||||
|
||||
s += fmt.Sprintln("Encoding masks: ")
|
||||
for _, v := range strings.Split(encoder.ValidStrings(), ",") {
|
||||
s += fmt.Sprintln(v + " ")
|
||||
_, _ = out.WriteString(`### Encoding masks
|
||||
|
||||
These are the valid options for the --encoding flag.
|
||||
|
||||
`)
|
||||
for _, v := range strings.Split(encoder.ValidStrings(), ", ") {
|
||||
_, _ = fmt.Fprintf(&out, "- `%s`\n", v)
|
||||
}
|
||||
s += fmt.Sprintln()
|
||||
_, _ = out.WriteRune('\n')
|
||||
|
||||
s += sprintExamples()
|
||||
sprintExamples(&out)
|
||||
|
||||
return s
|
||||
return out.String()
|
||||
}
|
||||
|
||||
func printList() {
|
||||
|
@ -2,6 +2,7 @@ package convmv
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/rclone/rclone/fs"
|
||||
"github.com/rclone/rclone/lib/encoder"
|
||||
@ -59,14 +60,17 @@ func (e example) output() string {
|
||||
}
|
||||
|
||||
// go run ./ convmv --help
|
||||
func sprintExamples() string {
|
||||
s := "Examples: \n\n"
|
||||
func sprintExamples(out *strings.Builder) {
|
||||
_, _ = fmt.Fprintf(out, `### Examples:
|
||||
|
||||
Here are some examples of rclone convmv in action.
|
||||
|
||||
`)
|
||||
for _, e := range examples {
|
||||
s += fmt.Sprintf("```\n%s\n", e.command())
|
||||
s += fmt.Sprintf("// Output: %s\n```\n\n", e.output())
|
||||
_, _ = fmt.Fprintf(out, "```\n%s\n", e.command())
|
||||
_, _ = fmt.Fprintf(out, "// Output: %s\n```\n\n", e.output())
|
||||
}
|
||||
Opt = ConvOpt{} // reset
|
||||
return s
|
||||
}
|
||||
|
||||
/* func sprintAllCharmapExamples() string {
|
||||
|
Loading…
x
Reference in New Issue
Block a user