diff --git a/config/config.go b/config/config.go index 04c83fe..f7a0480 100644 --- a/config/config.go +++ b/config/config.go @@ -30,17 +30,17 @@ func NewWithCtx(ctx *cli.Context) (*Config, error) { c := New() if ctx.NumFlags() > 0 { c.Core = engine.Config{ - SaveRoot: ctx.String(uploaderFlagSaveRoot), + SaveRoot: ctx.String(uploaderSaveRoot), ForceSync: true, } c.Driver = uploader.Config{ - Name: ctx.String(uploaderFlagDriver), - Region: ctx.String(uploaderFlagRegion), - Bucket: ctx.String(uploaderFlagBucket), - AccessKey: ctx.String(uploaderFlagAccessKey), - SecretKey: ctx.String(uploaderFlagSecretKey), + Name: ctx.String(uploaderDriver), + Region: ctx.String(uploaderRegion), + Bucket: ctx.String(uploaderBucket), + AccessKey: ctx.String(uploaderAccessKey), + SecretKey: ctx.String(uploaderSecretKey), } - if exclude := ctx.String(uploaderFlagExclude); exclude != "" { + if exclude := ctx.String(uploaderExclude); exclude != "" { c.Core.Excludes = strings.Split(exclude, ",") } } else if err := c.Parse(); err != nil { @@ -76,12 +76,13 @@ func (c *Config) Prompt() error { mask rune validate promptui.ValidateFunc }{ - {label: uploaderFlagDriver, value: &c.Driver.Name, validate: uploader.DriverValidate}, - {label: uploaderFlagRegion, value: &c.Driver.Region}, - {label: uploaderFlagBucket, value: &c.Driver.Bucket}, - {label: uploaderFlagAccessKey, value: &c.Driver.AccessKey}, - {label: uploaderFlagSecretKey, value: &c.Driver.SecretKey, mask: '*'}, - {label: uploaderFlagSaveRoot, value: &c.Core.SaveRoot}, + {label: uploaderDriver, value: &c.Driver.Name, validate: uploader.DriverValidate}, + {label: uploaderRegion, value: &c.Driver.Region}, + {label: uploaderBucket, value: &c.Driver.Bucket}, + {label: uploaderAccessKey, value: &c.Driver.AccessKey}, + {label: uploaderSecretKey, value: &c.Driver.SecretKey, mask: '*'}, + {label: uploaderSaveRoot, value: &c.Core.SaveRoot}, + {label: uploaderVisitHost, value: &c.Core.VisitHost}, } for _, prompt := range prompts { diff --git a/config/flags.go b/config/flags.go index 970f40e..dffaace 100644 --- a/config/flags.go +++ b/config/flags.go @@ -4,13 +4,14 @@ import "github.com/urfave/cli" const ( // uploader flags - uploaderFlagDriver = "driver" - uploaderFlagRegion = "region" - uploaderFlagAccessKey = "access_key" - uploaderFlagSecretKey = "secret_key" - uploaderFlagBucket = "bucket" - uploaderFlagExclude = "exclude" - uploaderFlagSaveRoot = "save_root" + uploaderDriver = "driver" + uploaderRegion = "region" + uploaderAccessKey = "access_key" + uploaderSecretKey = "secret_key" + uploaderBucket = "bucket" + uploaderExclude = "exclude" + uploaderSaveRoot = "save_root" + uploaderVisitHost = "visit_host" // uploader environments uploaderEnvAccessKey = "UPTOC_UPLOADER_AK" @@ -20,34 +21,34 @@ const ( // Flags defined the support flags for the cli var Flags = []cli.Flag{ cli.StringFlag{ - Name: uploaderFlagDriver, + Name: uploaderDriver, Usage: "specify cloud storage engine", Value: "oss", }, cli.StringFlag{ - Name: uploaderFlagRegion, + Name: uploaderRegion, Usage: "specify region of the cloud platform", }, cli.StringFlag{ - Name: uploaderFlagBucket, + Name: uploaderBucket, Usage: "specify bucket name of the cloud platform", }, cli.StringFlag{ - Name: uploaderFlagAccessKey, + Name: uploaderAccessKey, Usage: "specify key id of the cloud platform", EnvVar: uploaderEnvAccessKey, }, cli.StringFlag{ - Name: uploaderFlagSecretKey, + Name: uploaderSecretKey, Usage: "specify key secret of the cloud platform", EnvVar: uploaderEnvSecretKey, }, cli.StringFlag{ - Name: uploaderFlagExclude, + Name: uploaderExclude, Usage: "specify exclude the given comma separated directories (example: --exclude=.cache,test)", }, cli.StringFlag{ - Name: uploaderFlagSaveRoot, + Name: uploaderSaveRoot, Usage: "specify remote directory, default is root", }, }