2016-08-05 16:12:27 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
2017-09-19 15:59:19 +00:00
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
2016-08-05 16:12:27 +00:00
|
|
|
"github.com/ncw/rclone/cmd"
|
|
|
|
"github.com/ncw/rclone/fs"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2016-10-22 11:05:45 +00:00
|
|
|
cmd.Root.AddCommand(commandDefintion)
|
2016-08-05 16:12:27 +00:00
|
|
|
}
|
|
|
|
|
2016-10-22 11:05:45 +00:00
|
|
|
var commandDefintion = &cobra.Command{
|
2017-09-19 15:59:19 +00:00
|
|
|
Use: "config [function]",
|
2016-08-05 16:12:27 +00:00
|
|
|
Short: `Enter an interactive configuration session.`,
|
2017-09-19 15:59:19 +00:00
|
|
|
Long: "`rclone config`" + `
|
|
|
|
enters an interactive configuration sessions where you can setup
|
|
|
|
new remotes and manage existing ones. You may also set or remove a password to
|
|
|
|
protect your configuration.
|
|
|
|
|
|
|
|
Additional functions:
|
|
|
|
|
|
|
|
* ` + "`rclone config edit`" + ` – same as above
|
|
|
|
* ` + "`rclone config file`" + ` – show path of configuration file in use
|
|
|
|
* ` + "`rclone config show`" + ` – print (decrypted) config file
|
|
|
|
`,
|
2016-08-05 16:12:27 +00:00
|
|
|
Run: func(command *cobra.Command, args []string) {
|
2017-09-19 15:59:19 +00:00
|
|
|
cmd.CheckArgs(0, 1, command, args)
|
|
|
|
if len(args) == 0 {
|
|
|
|
fs.EditConfig()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
switch args[0] {
|
|
|
|
case "edit":
|
|
|
|
fs.EditConfig()
|
|
|
|
case "show":
|
|
|
|
fs.ShowConfig()
|
|
|
|
case "file":
|
|
|
|
fs.ShowConfigLocation()
|
|
|
|
default:
|
|
|
|
fmt.Fprintf(os.Stderr, "Unknown subcommand %q, %s only supports edit, show and file.\n", args[0], command.Name())
|
|
|
|
}
|
2016-08-05 16:12:27 +00:00
|
|
|
},
|
|
|
|
}
|