Skip to content

Commit f656cae

Browse files
committed
Add --all option to updateuser command
1 parent 48199f6 commit f656cae

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

baidupcs_py/app/app.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,22 +384,27 @@ def who(ctx, user_id, show_encrypt_password):
384384

385385
@app.command()
386386
@click.argument("user_ids", type=int, nargs=-1, default=None, required=False)
387+
@click.option("--all", is_flag=True, help="更新所有用户信息")
387388
@click.pass_context
388389
@handle_error
389-
def updateuser(ctx, user_ids):
390+
def updateuser(ctx, user_ids, all):
390391
"""更新用户信息 (默认更新当前用户信息)
391392
392393
也可指定多个 `user_id`
393394
"""
394395

395-
am = ctx.obj.account_manager
396+
am: AccountManager = ctx.obj.account_manager
396397
if not user_ids:
397-
user_ids = [am._who]
398+
if all:
399+
user_ids = [a.user.user_id for a in am.accounts]
400+
else:
401+
user_ids = [am._who]
398402

399403
for user_id in user_ids:
400404
am.update(user_id)
401405
account = am.who(user_id)
402-
display_user_info(account.user)
406+
if account:
407+
display_user_info(account.user)
403408

404409
am.save()
405410

0 commit comments

Comments
 (0)