2022-08-28 13:21:57 +02:00
|
|
|
// Package authorize provides the authorize command.
|
2016-08-05 18:12:27 +02:00
|
|
|
package authorize
|
|
|
|
|
|
|
|
import (
|
2020-11-05 19:02:26 +01:00
|
|
|
"context"
|
|
|
|
|
2019-07-28 19:47:38 +02:00
|
|
|
"github.com/rclone/rclone/cmd"
|
|
|
|
"github.com/rclone/rclone/fs/config"
|
2019-10-26 21:19:22 +02:00
|
|
|
"github.com/rclone/rclone/fs/config/flags"
|
2016-08-05 18:12:27 +02:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
2019-10-26 21:19:22 +02:00
|
|
|
var (
|
|
|
|
noAutoBrowser bool
|
2023-02-24 16:08:38 +01:00
|
|
|
template string
|
2019-10-26 21:19:22 +02:00
|
|
|
)
|
|
|
|
|
2016-08-05 18:12:27 +02:00
|
|
|
func init() {
|
2019-10-11 17:58:11 +02:00
|
|
|
cmd.Root.AddCommand(commandDefinition)
|
2019-10-26 21:19:22 +02:00
|
|
|
cmdFlags := commandDefinition.Flags()
|
2023-07-10 19:34:10 +02:00
|
|
|
flags.BoolVarP(cmdFlags, &noAutoBrowser, "auth-no-open-browser", "", false, "Do not automatically open auth link in default browser", "")
|
|
|
|
flags.StringVarP(cmdFlags, &template, "template", "", "", "The path to a custom Go template for generating HTML responses", "")
|
2016-08-05 18:12:27 +02:00
|
|
|
}
|
|
|
|
|
2019-10-11 17:58:11 +02:00
|
|
|
var commandDefinition = &cobra.Command{
|
2016-08-05 18:12:27 +02:00
|
|
|
Use: "authorize",
|
|
|
|
Short: `Remote authorization.`,
|
|
|
|
Long: `
|
|
|
|
Remote authorization. Used to authorize a remote or headless
|
|
|
|
rclone from a machine with a browser - use as instructed by
|
2019-10-26 21:19:22 +02:00
|
|
|
rclone config.
|
|
|
|
|
2023-02-24 16:08:38 +01:00
|
|
|
Use --auth-no-open-browser to prevent rclone to open auth
|
|
|
|
link in default browser automatically.
|
|
|
|
|
|
|
|
Use --template to generate HTML output via a custom Go template. If a blank string is provided as an argument to this flag, the default template is used.`,
|
2022-11-26 23:40:49 +01:00
|
|
|
Annotations: map[string]string{
|
|
|
|
"versionIntroduced": "v1.27",
|
2023-07-10 19:34:10 +02:00
|
|
|
// "groups": "",
|
2022-11-26 23:40:49 +01:00
|
|
|
},
|
2021-03-13 15:54:26 +01:00
|
|
|
RunE: func(command *cobra.Command, args []string) error {
|
2016-08-05 18:12:27 +02:00
|
|
|
cmd.CheckArgs(1, 3, command, args)
|
2023-02-24 16:08:38 +01:00
|
|
|
return config.Authorize(context.Background(), args, noAutoBrowser, template)
|
2016-08-05 18:12:27 +02:00
|
|
|
},
|
|
|
|
}
|