Add help to remote chooser in rclone config - fixes #43

s3-about
Nick Craig-Wood 2016-02-15 18:11:53 +00:00
parent a3b4c8a0f2
commit e08e35984c
13 changed files with 73 additions and 32 deletions

View File

@ -63,8 +63,9 @@ var (
// Register with Fs
func init() {
fs.Register(&fs.RegInfo{
Name: "amazon cloud drive",
NewFs: NewFs,
Name: "amazon cloud drive",
Description: "Amazon Cloud Drive",
NewFs: NewFs,
Config: func(name string) {
err := oauthutil.Config("amazon cloud drive", name, acdConfig)
if err != nil {

View File

@ -40,8 +40,9 @@ const (
// Register with Fs
func init() {
fs.Register(&fs.RegInfo{
Name: "b2",
NewFs: NewFs,
Name: "b2",
Description: "Backblaze B2",
NewFs: NewFs,
Options: []fs.Option{{
Name: "account",
Help: "Account ID",

View File

@ -85,8 +85,9 @@ var (
// Register with Fs
func init() {
fs.Register(&fs.RegInfo{
Name: "drive",
NewFs: NewFs,
Name: "drive",
Description: "Google Drive",
NewFs: NewFs,
Config: func(name string) {
err := oauthutil.Config("drive", name, driveConfig)
if err != nil {

View File

@ -45,9 +45,10 @@ var (
// Register with Fs
func init() {
fs.Register(&fs.RegInfo{
Name: "dropbox",
NewFs: NewFs,
Config: configHelper,
Name: "dropbox",
Description: "Dropbox",
NewFs: NewFs,
Config: configHelper,
Options: []fs.Option{{
Name: "app_key",
Help: "Dropbox App Key - leave blank normally.",

View File

@ -673,14 +673,26 @@ func ChooseOption(o *Option) string {
return ReadLine()
}
// fsOption returns an Option describing the possible remotes
func fsOption() *Option {
o := &Option{
Name: "Storage",
Help: "Type of storage to configure.",
}
for _, item := range fsRegistry {
example := OptionExample{
Value: item.Name,
Help: item.Description,
}
o.Examples = append(o.Examples, example)
}
o.Examples.Sort()
return o
}
// NewRemote make a new remote from its name
func NewRemote(name string) {
fmt.Printf("What type of source is it?\n")
types := []string{}
for _, item := range fsRegistry {
types = append(types, item.Name)
}
newType := Choose("type", types, nil, false)
newType := ChooseOption(fsOption())
ConfigFile.SetValue(name, "type", newType)
fs, err := Find(newType)
if err != nil {

View File

@ -7,6 +7,7 @@ import (
"log"
"path/filepath"
"regexp"
"sort"
"time"
)
@ -36,6 +37,8 @@ var (
type RegInfo struct {
// Name of this fs
Name string
// Description of this fs - defaults to Name
Description string
// Create a new file system. If root refers to an existing
// object, then it should return a Fs which only returns that
// object.
@ -51,9 +54,24 @@ type Option struct {
Name string
Help string
Optional bool
Examples []OptionExample
Examples OptionExamples
}
// OptionExamples is a slice of examples
type OptionExamples []OptionExample
// Len is part of sort.Interface.
func (os OptionExamples) Len() int { return len(os) }
// Swap is part of sort.Interface.
func (os OptionExamples) Swap(i, j int) { os[i], os[j] = os[j], os[i] }
// Less is part of sort.Interface.
func (os OptionExamples) Less(i, j int) bool { return os[i].Help < os[j].Help }
// Sort sorts an OptionExamples
func (os OptionExamples) Sort() { sort.Sort(os) }
// OptionExample describes an example for an Option
type OptionExample struct {
Value string

View File

@ -56,8 +56,9 @@ var (
// Register with Fs
func init() {
fs.Register(&fs.RegInfo{
Name: "google cloud storage",
NewFs: NewFs,
Name: "google cloud storage",
Description: "Google Cloud Storage (this is not Google Drive)",
NewFs: NewFs,
Config: func(name string) {
err := oauthutil.Config("google cloud storage", name, storageConfig)
if err != nil {

View File

@ -45,8 +45,9 @@ var (
// Register with Fs
func init() {
fs.Register(&fs.RegInfo{
Name: "hubic",
NewFs: NewFs,
Name: "hubic",
Description: "Hubic",
NewFs: NewFs,
Config: func(name string) {
err := oauthutil.Config("hubic", name, oauthConfig)
if err != nil {

View File

@ -20,8 +20,9 @@ import (
// Register with Fs
func init() {
fsi := &fs.RegInfo{
Name: "local",
NewFs: NewFs,
Name: "local",
Description: "Local Disk",
NewFs: NewFs,
Options: []fs.Option{fs.Option{
Name: "nounc",
Help: "Disable UNC (long path names) conversion on Windows",

View File

@ -56,8 +56,9 @@ var (
// Register with Fs
func init() {
fs.Register(&fs.RegInfo{
Name: "onedrive",
NewFs: NewFs,
Name: "onedrive",
Description: "Microsoft OneDrive",
NewFs: NewFs,
Config: func(name string) {
err := oauthutil.Config("onedrive", name, oauthConfig)
if err != nil {

View File

@ -41,8 +41,9 @@ import (
// Register with Fs
func init() {
fs.Register(&fs.RegInfo{
Name: "s3",
NewFs: NewFs,
Name: "s3",
Description: "Amazon S3 (also Dreamhost, Ceph)",
NewFs: NewFs,
// AWS endpoints: http://docs.amazonwebservices.com/general/latest/gr/rande.html#s3_region
Options: []fs.Option{{
Name: "env_auth",
@ -94,10 +95,10 @@ func init() {
Help: "South America (Sao Paulo) Region\nNeeds location constraint sa-east-1.",
}, {
Value: "other-v2-signature",
Help: "If using an S3 clone that only understands v2 signatures - eg Ceph - set this and make sure you set the endpoint.",
Help: "If using an S3 clone that only understands v2 signatures\neg Ceph/Dreamhost\nset this and make sure you set the endpoint.",
}, {
Value: "other-v4-signature",
Help: "If using an S3 clone that understands v4 signatures set this and make sure you set the endpoint.",
Help: "If using an S3 clone that understands v4 signatures set this\nand make sure you set the endpoint.",
}},
}, {
Name: "endpoint",

View File

@ -30,8 +30,9 @@ var (
// Register with Fs
func init() {
fs.Register(&fs.RegInfo{
Name: "swift",
NewFs: NewFs,
Name: "swift",
Description: "Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)",
NewFs: NewFs,
Options: []fs.Option{{
Name: "user",
Help: "User name to log in.",

View File

@ -42,8 +42,9 @@ var (
// Register with Fs
func init() {
fs.Register(&fs.RegInfo{
Name: "yandex",
NewFs: NewFs,
Name: "yandex",
Description: "Yandex Disk",
NewFs: NewFs,
Config: func(name string) {
err := oauthutil.Config("yandex", name, oauthConfig)
if err != nil {