|
@@ -62,7 +62,7 @@ var updateAccCmd = &cobra.Command{
|
|
fmt.Printf("invalid app. Accepted values are 'photos', 'locker', 'auth'")
|
|
fmt.Printf("invalid app. Accepted values are 'photos', 'locker', 'auth'")
|
|
|
|
|
|
}
|
|
}
|
|
- err := ctrl.UpdateAccount(context.Background(), model.UpdateAccountParams{
|
|
|
|
|
|
+ err := ctrl.UpdateAccount(context.Background(), model.AccountCommandParams{
|
|
Email: email,
|
|
Email: email,
|
|
App: api.StringToApp(app),
|
|
App: api.StringToApp(app),
|
|
ExportDir: &exportDir,
|
|
ExportDir: &exportDir,
|
|
@@ -73,12 +73,49 @@ var updateAccCmd = &cobra.Command{
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Subcommand for 'account update'
|
|
|
|
+var getTokenCmd = &cobra.Command{
|
|
|
|
+ Use: "get-token",
|
|
|
|
+ Short: "Get token for an account for a specific app",
|
|
|
|
+ Run: func(cmd *cobra.Command, args []string) {
|
|
|
|
+ recoverWithLog()
|
|
|
|
+ app, _ := cmd.Flags().GetString("app")
|
|
|
|
+ email, _ := cmd.Flags().GetString("email")
|
|
|
|
+ if email == "" {
|
|
|
|
+
|
|
|
|
+ fmt.Println("email must be specified, use --help for more information")
|
|
|
|
+ // print help
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ validApps := map[string]bool{
|
|
|
|
+ "photos": true,
|
|
|
|
+ "locker": true,
|
|
|
|
+ "auth": true,
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if !validApps[app] {
|
|
|
|
+ fmt.Printf("invalid app. Accepted values are 'photos', 'locker', 'auth'")
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ err := ctrl.GetToken(context.Background(), model.AccountCommandParams{
|
|
|
|
+ Email: email,
|
|
|
|
+ App: api.StringToApp(app),
|
|
|
|
+ })
|
|
|
|
+ if err != nil {
|
|
|
|
+ fmt.Printf("Error updating account: %v\n", err)
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+}
|
|
|
|
+
|
|
func init() {
|
|
func init() {
|
|
// Add 'config' subcommands to the root command
|
|
// Add 'config' subcommands to the root command
|
|
rootCmd.AddCommand(accountCmd)
|
|
rootCmd.AddCommand(accountCmd)
|
|
// Add 'config' subcommands to the 'config' command
|
|
// Add 'config' subcommands to the 'config' command
|
|
updateAccCmd.Flags().String("dir", "", "update export directory")
|
|
updateAccCmd.Flags().String("dir", "", "update export directory")
|
|
- updateAccCmd.Flags().String("email", "", "email address of the account to update")
|
|
|
|
|
|
+ updateAccCmd.Flags().String("email", "", "email address of the account")
|
|
updateAccCmd.Flags().String("app", "photos", "Specify the app, default is 'photos'")
|
|
updateAccCmd.Flags().String("app", "photos", "Specify the app, default is 'photos'")
|
|
- accountCmd.AddCommand(listAccCmd, addAccCmd, updateAccCmd)
|
|
|
|
|
|
+ getTokenCmd.Flags().String("email", "", "email address of the account")
|
|
|
|
+ getTokenCmd.Flags().String("app", "photos", "Specify the app, default is 'photos'")
|
|
|
|
+ accountCmd.AddCommand(listAccCmd, addAccCmd, updateAccCmd, getTokenCmd)
|
|
}
|
|
}
|