mirror of
https://github.com/rclone/rclone.git
synced 2026-06-28 09:55:16 -04:00
Option help strings are also used to generate the website documentation, so some contain markdown links with root-relative targets such as [encoding section in the overview](/overview/#encoding). These render correctly on rclone.org but are confusing in the interactive config prompt, where the user sees the raw markdown and the link has no reachable root. Rewrite such links to text (https://rclone.org/path) when showing an option's help in the interactive config. The raw help is left unchanged so documentation generation is unaffected.
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package config
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestRenderHelpForTerminal(t *testing.T) {
|
|
for _, test := range []struct {
|
|
name string
|
|
help string
|
|
want string
|
|
}{
|
|
{
|
|
name: "no link",
|
|
help: "The encoding for the backend.",
|
|
want: "The encoding for the backend.",
|
|
},
|
|
{
|
|
name: "root relative link",
|
|
help: "See the [encoding section in the overview](/overview/#encoding) for more info.",
|
|
want: "See the encoding section in the overview (https://rclone.org/overview/#encoding) for more info.",
|
|
},
|
|
{
|
|
name: "root relative link without anchor",
|
|
help: "See [rclone serve sftp](/commands/rclone_serve_sftp) for details.",
|
|
want: "See rclone serve sftp (https://rclone.org/commands/rclone_serve_sftp) for details.",
|
|
},
|
|
{
|
|
name: "multiple links",
|
|
help: "[the time option docs](/docs/#time-options) and [authentication docs](/azureblob#authentication).",
|
|
want: "the time option docs (https://rclone.org/docs/#time-options) and authentication docs (https://rclone.org/azureblob#authentication).",
|
|
},
|
|
{
|
|
name: "absolute url left untouched",
|
|
help: "See [rclone forum](https://forum.rclone.org/) for help.",
|
|
want: "See [rclone forum](https://forum.rclone.org/) for help.",
|
|
},
|
|
} {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
assert.Equal(t, test.want, renderHelpForTerminal(test.help))
|
|
})
|
|
}
|
|
}
|