mirror of
https://github.com/rclone/rclone.git
synced 2025-08-10 22:23:57 +02:00
convmv: fix spurious "error running command echo" on Windows
Before this change the help for convmv was generated by running the examples each time rclone started up. Unfortunately this involved running the echo command which did not work on Windows. This pre-generates the help into `transform.md` and embeds it. It can be re-generated with `go generate` which is a better solution. See: https://forum.rclone.org/t/invoke-of-1-70-0-complains-of-echo-not-found/51618
This commit is contained in:
@ -1,9 +1,12 @@
|
||||
// Package transform holds functions for path name transformations
|
||||
//
|
||||
//go:generate go run gen_help.go transform.md
|
||||
package transform
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
_ "embed"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
@ -24,6 +27,16 @@ import (
|
||||
"golang.org/x/text/unicode/norm"
|
||||
)
|
||||
|
||||
//go:embed transform.md
|
||||
var help string
|
||||
|
||||
// Help returns the help string cleaned up to simplify appending
|
||||
func Help() string {
|
||||
// Chop off auto generated message
|
||||
nl := strings.IndexRune(help, '\n')
|
||||
return strings.TrimSpace(help[nl:]) + "\n\n"
|
||||
}
|
||||
|
||||
// Path transforms a path s according to the --name-transform options in use
|
||||
//
|
||||
// If no transforms are in use, s is returned unchanged
|
||||
@ -53,7 +66,7 @@ func Path(ctx context.Context, s string, isDir bool) string {
|
||||
fs.Errorf(s, "Failed to transform: %v", err)
|
||||
}
|
||||
}
|
||||
if old != s && !generatingHelpText {
|
||||
if old != s {
|
||||
fs.Debugf(old, "transformed to: %v", s)
|
||||
}
|
||||
if strings.Count(old, "/") != strings.Count(s, "/") {
|
||||
@ -181,7 +194,7 @@ func transformPathSegment(s string, t transform) (string, error) {
|
||||
case ConvMacintosh:
|
||||
return encodeWithReplacement(s, charmap.Macintosh), nil
|
||||
case ConvCharmap:
|
||||
var cmapType fs.Enum[cmapChoices]
|
||||
var cmapType CharmapChoices
|
||||
err := cmapType.Set(t.value)
|
||||
if err != nil {
|
||||
return s, err
|
||||
|
Reference in New Issue
Block a user