Update account cmd and documentation

This commit is contained in:
Neeraj Gupta 2023-10-18 12:41:20 +05:30
parent 1cb5414e79
commit fd7aac9b44
5 changed files with 27 additions and 4 deletions

View file

@ -15,8 +15,17 @@
```shell
ente-cli account list
```
* Change export directory
```shell
ente-cli account update --email yourEmail@example.com --dir ~/photos
```
## Export
* Start export
```shell
ente-cli export
```
## Testing

View file

@ -44,7 +44,12 @@ var updateAccCmd = &cobra.Command{
app, _ := cmd.Flags().GetString("app")
email, _ := cmd.Flags().GetString("email")
if email == "" {
fmt.Printf("email must be specified")
fmt.Println("email must be specified")
return
}
if exportDir == "" {
fmt.Println("dir param must be specified")
return
}
validApps := map[string]bool{
@ -72,7 +77,7 @@ func init() {
// Add 'config' subcommands to the root command
rootCmd.AddCommand(accountCmd)
// 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("app", "photos", "Specify the app, default is 'photos'")
accountCmd.AddCommand(listAccCmd, addAccCmd, updateAccCmd)

View file

@ -154,7 +154,7 @@ func (c *ClICtrl) UpdateAccount(ctx context.Context, params model.UpdateAccountP
}
}
if acc == nil {
return fmt.Errorf("account not found")
return fmt.Errorf("account not found, use `account list` to list accounts")
}
if params.ExportDir != nil && *params.ExportDir != "" {
_, err := internal.ValidateDirForWrite(*params.ExportDir)

View file

@ -2,6 +2,7 @@ package pkg
import (
"cli-go/internal"
"cli-go/internal/api"
"cli-go/pkg/model"
"context"
"encoding/base64"
@ -31,6 +32,10 @@ func (c *ClICtrl) Export() error {
log.Printf("Skip export, error: %v while validing exportDir %s\n", err, account.ExportDir)
continue
}
if account.App == api.AppAuth {
log.Printf("Skip account %s: auth export is not supported", account.Email)
continue
}
log.Println("start sync")
err = c.SyncAccount(account)
if err != nil {

View file

@ -24,6 +24,10 @@ do
if [ "$OS" == "darwin" ]; then
BINARY_NAME="ente-cli-mac"
fi
if [ "$OS" == "linux" ]; then
BINARY_NAME="ente-cli-linux"
fi
# make bin directory if it doesn't exist
mkdir -p bin