mirror of
https://github.com/ihabunek/toot
synced 2024-12-23 15:37:47 +01:00
Changed parameters for list cmds
Title is now a positional parameter. Also added some error handling in the command processing for looking up list IDs per @ihabunek 's suggestions
This commit is contained in:
parent
c12c53d719
commit
47b182a05b
@ -430,8 +430,12 @@ def lists(app, user, args):
|
||||
|
||||
|
||||
def list_accounts(app, user, args):
|
||||
id = args.id if args.id else api.find_list_id(app, user, args.title)
|
||||
response = api.get_list_accounts(app, user, id)
|
||||
list_id = args.id if args.id else api.find_list_id(app, user, args.title)
|
||||
if not list_id:
|
||||
print_out("<red>List not found</red>")
|
||||
return
|
||||
|
||||
response = api.get_list_accounts(app, user, list_id)
|
||||
print_list_accounts(response)
|
||||
|
||||
|
||||
@ -441,12 +445,16 @@ def list_create(app, user, args):
|
||||
|
||||
|
||||
def list_delete(app, user, args):
|
||||
id = args.id if args.id else api.find_list_id(app, user, args.title)
|
||||
api.delete_list(app, user, id)
|
||||
list_id = args.id if args.id else api.find_list_id(app, user, args.title)
|
||||
if not list_id:
|
||||
print_out("<red>List not found</red>")
|
||||
return
|
||||
|
||||
api.delete_list(app, user, list_id)
|
||||
print_out(f"<green>✓ List \"{args.title if args.title else args.id}\"</green> <red>deleted.</red>")
|
||||
|
||||
|
||||
def list_add_account(app, user, args):
|
||||
def list_add(app, user, args):
|
||||
list_id = args.id if args.id else api.find_list_id(app, user, args.title)
|
||||
if not list_id:
|
||||
print_out("<red>List not found</red>")
|
||||
@ -455,14 +463,11 @@ def list_add_account(app, user, args):
|
||||
if not account:
|
||||
print_out("<red>Account not found</red>")
|
||||
return
|
||||
try:
|
||||
api.add_accounts_to_list(app, user, list_id, [account['id']])
|
||||
print_out(f"<green>✓ Added account \"{args.account}\"</green>")
|
||||
except Exception as ex:
|
||||
print_out(f"<red>{ex}</red>")
|
||||
api.add_accounts_to_list(app, user, list_id, [account['id']])
|
||||
print_out(f"<green>✓ Added account \"{args.account}\"</green>")
|
||||
|
||||
|
||||
def list_remove_account(app, user, args):
|
||||
def list_remove(app, user, args):
|
||||
list_id = args.id if args.id else api.find_list_id(app, user, args.title)
|
||||
if not list_id:
|
||||
print_out("<red>List not found</red>")
|
||||
@ -471,11 +476,8 @@ def list_remove_account(app, user, args):
|
||||
if not account:
|
||||
print_out("<red>Account not found</red>")
|
||||
return
|
||||
try:
|
||||
api.remove_accounts_from_list(app, user, list_id, [account['id']])
|
||||
print_out(f"<green>✓ Removed account \"{args.account}\"</green>")
|
||||
except Exception as ex:
|
||||
print_out(f"<red>{ex}</red>")
|
||||
api.remove_accounts_from_list(app, user, list_id, [account['id']])
|
||||
print_out(f"<green>✓ Removed account \"{args.account}\"</green>")
|
||||
|
||||
|
||||
def mute(app, user, args):
|
||||
|
@ -734,12 +734,14 @@ LIST_COMMANDS = [
|
||||
Command(
|
||||
name="list_accounts",
|
||||
description="List the accounts in a list",
|
||||
arguments=[(["--id"], {
|
||||
"type": str,
|
||||
"help": "ID of the list"
|
||||
}),
|
||||
(["--title"], {
|
||||
arguments=[
|
||||
(["--id"], {
|
||||
"type": str,
|
||||
"help": "ID of the list"
|
||||
}),
|
||||
(["title"], {
|
||||
"type": str,
|
||||
"nargs": "?",
|
||||
"help": "title of the list"
|
||||
}),
|
||||
],
|
||||
@ -749,11 +751,7 @@ LIST_COMMANDS = [
|
||||
name="list_create",
|
||||
description="Create a list",
|
||||
arguments=[
|
||||
(["--id"], {
|
||||
"type": str,
|
||||
"help": "ID of the list"
|
||||
}),
|
||||
(["--title"], {
|
||||
(["title"], {
|
||||
"type": str,
|
||||
"help": "title of the list"
|
||||
}),
|
||||
@ -772,26 +770,28 @@ LIST_COMMANDS = [
|
||||
"type": str,
|
||||
"help": "ID of the list"
|
||||
}),
|
||||
(["--title"], {
|
||||
(["title"], {
|
||||
"type": str,
|
||||
"nargs": "?",
|
||||
"help": "title of the list"
|
||||
}),
|
||||
],
|
||||
require_auth=True,
|
||||
),
|
||||
Command(
|
||||
name="list_add_account",
|
||||
name="list_add",
|
||||
description="Add account to list",
|
||||
arguments=[
|
||||
(["--id"], {
|
||||
"type": str,
|
||||
"help": "ID of the list"
|
||||
}),
|
||||
(["--title"], {
|
||||
(["title"], {
|
||||
"type": str,
|
||||
"nargs": "?",
|
||||
"help": "title of the list"
|
||||
}),
|
||||
(["--account"], {
|
||||
(["account"], {
|
||||
"type": str,
|
||||
"help": "Account to add"
|
||||
}),
|
||||
@ -799,18 +799,19 @@ LIST_COMMANDS = [
|
||||
require_auth=True,
|
||||
),
|
||||
Command(
|
||||
name="list_remove_account",
|
||||
name="list_remove",
|
||||
description="Remove account from list",
|
||||
arguments=[
|
||||
(["--id"], {
|
||||
"type": str,
|
||||
"help": "ID of the list"
|
||||
}),
|
||||
(["--title"], {
|
||||
(["title"], {
|
||||
"type": str,
|
||||
"nargs": "?",
|
||||
"help": "title of the list"
|
||||
}),
|
||||
(["--account"], {
|
||||
(["account"], {
|
||||
"type": str,
|
||||
"help": "Account to remove"
|
||||
}),
|
||||
|
Loading…
Reference in New Issue
Block a user