func readDropBoxAppConfig(appName string) (*DropBoxAppConfig, error) { s := scan.CliScan{ Scans: []scan.Scan{ {Name: "token", Value: "", Usage: "please your dropbox accessToken", Env: "", }, }, } ac := appConfig.NewDefaultAppConfig(appName) data, err := ac.ReadAppConfig() accessToken := string(data) if err != nil || accessToken == "" { // OAuth jump open.Run(accessTokenURL) // Scan accessToken accessToken = s.Scan("token") // config write if err := ac.WriteAppConfig([]byte(accessToken)); err != nil { return nil, err } } return &DropBoxAppConfig{*ac}, nil }
func doDeleteConfig(c *cli.Context) { ac := appConfig.NewDefaultAppConfig(c.App.Name) if err := ac.RemoveAppConfig(); err != nil { log.Fatal(err) } fmt.Println("delete config successful!") fmt.Println("path: ", ac.ConfigDirPath) }