mirror of
https://github.com/ihabunek/toot.git
synced 2024-11-03 04:17:21 -05:00
Group commands contextually in print_help
This commit is contained in:
parent
a57cb5d251
commit
0198bd3af7
22
README.rst
22
README.rst
@ -36,21 +36,31 @@ Running ``toot <command> -h`` shows the documentation for the given command.
|
||||
|
||||
toot - a Mastodon CLI client
|
||||
|
||||
Usage:
|
||||
Authentication:
|
||||
toot login Log into a Mastodon instance
|
||||
toot login_2fa Log in using two factor authentication (experimental)
|
||||
toot logout Log out, delete stored access keys
|
||||
toot auth Show stored credentials
|
||||
|
||||
Read:
|
||||
toot whoami Display logged in user details
|
||||
toot whois Display user details
|
||||
toot post Post a status text to your timeline
|
||||
toot upload Upload an image or video file
|
||||
toot whois Display account details
|
||||
toot search Search for users or hashtags
|
||||
toot follow Follow an account
|
||||
toot unfollow Unfollow an account
|
||||
toot timeline Show recent items in your public timeline
|
||||
toot curses An experimental timeline app.
|
||||
|
||||
Post:
|
||||
toot post Post a status text to your timeline
|
||||
toot upload Upload an image or video file
|
||||
|
||||
Accounts:
|
||||
toot follow Follow an account
|
||||
toot unfollow Unfollow an account
|
||||
toot mute Mute an account
|
||||
toot unmute Unmute an account
|
||||
toot block Block an account
|
||||
toot unblock Unblock an account
|
||||
|
||||
To get help for each command run:
|
||||
toot <command> --help
|
||||
|
||||
|
@ -32,7 +32,7 @@ account_arg = (["account"], {
|
||||
})
|
||||
|
||||
|
||||
COMMANDS = [
|
||||
AUTH_COMMANDS = [
|
||||
Command(
|
||||
name="login",
|
||||
description="Log into a Mastodon instance",
|
||||
@ -57,6 +57,9 @@ COMMANDS = [
|
||||
arguments=[],
|
||||
require_auth=False,
|
||||
),
|
||||
]
|
||||
|
||||
READ_COMMANDS = [
|
||||
Command(
|
||||
name="whoami",
|
||||
description="Display logged in user details",
|
||||
@ -65,7 +68,7 @@ COMMANDS = [
|
||||
),
|
||||
Command(
|
||||
name="whois",
|
||||
description="Display user details",
|
||||
description="Display account details",
|
||||
arguments=[
|
||||
(["account"], {
|
||||
"help": "account name or numeric ID"
|
||||
@ -73,6 +76,36 @@ COMMANDS = [
|
||||
],
|
||||
require_auth=True,
|
||||
),
|
||||
Command(
|
||||
name="search",
|
||||
description="Search for users or hashtags",
|
||||
arguments=[
|
||||
(["query"], {
|
||||
"help": "the search query",
|
||||
}),
|
||||
(["-r", "--resolve"], {
|
||||
"action": 'store_true',
|
||||
"default": False,
|
||||
"help": "Resolve non-local accounts",
|
||||
}),
|
||||
],
|
||||
require_auth=True,
|
||||
),
|
||||
Command(
|
||||
name="timeline",
|
||||
description="Show recent items in your public timeline",
|
||||
arguments=[],
|
||||
require_auth=True,
|
||||
),
|
||||
Command(
|
||||
name="curses",
|
||||
description="An experimental timeline app.",
|
||||
arguments=[],
|
||||
require_auth=True,
|
||||
),
|
||||
]
|
||||
|
||||
POST_COMMANDS = [
|
||||
Command(
|
||||
name="post",
|
||||
description="Post a status text to your timeline",
|
||||
@ -103,21 +136,9 @@ COMMANDS = [
|
||||
],
|
||||
require_auth=True,
|
||||
),
|
||||
Command(
|
||||
name="search",
|
||||
description="Search for users or hashtags",
|
||||
arguments=[
|
||||
(["query"], {
|
||||
"help": "the search query",
|
||||
}),
|
||||
(["-r", "--resolve"], {
|
||||
"action": 'store_true',
|
||||
"default": False,
|
||||
"help": "Resolve non-local accounts",
|
||||
}),
|
||||
],
|
||||
require_auth=True,
|
||||
),
|
||||
]
|
||||
|
||||
ACCOUNTS_COMMANDS = [
|
||||
Command(
|
||||
name="follow",
|
||||
description="Follow an account",
|
||||
@ -166,30 +187,29 @@ COMMANDS = [
|
||||
],
|
||||
require_auth=True,
|
||||
),
|
||||
Command(
|
||||
name="timeline",
|
||||
description="Show recent items in your public timeline",
|
||||
arguments=[],
|
||||
require_auth=True,
|
||||
),
|
||||
Command(
|
||||
name="curses",
|
||||
description="An experimental timeline app.",
|
||||
arguments=[],
|
||||
require_auth=True,
|
||||
),
|
||||
]
|
||||
|
||||
COMMANDS = AUTH_COMMANDS + READ_COMMANDS + POST_COMMANDS + ACCOUNTS_COMMANDS
|
||||
|
||||
|
||||
def print_usage():
|
||||
print(CLIENT_NAME)
|
||||
print("")
|
||||
print("Usage:")
|
||||
|
||||
max_name_len = max(len(command.name) for command in COMMANDS)
|
||||
|
||||
for command in COMMANDS:
|
||||
print(" toot", command.name.ljust(max_name_len + 2), command.description)
|
||||
groups = [
|
||||
("Authentication", AUTH_COMMANDS),
|
||||
("Read", READ_COMMANDS),
|
||||
("Post", POST_COMMANDS),
|
||||
("Accounts", ACCOUNTS_COMMANDS),
|
||||
]
|
||||
|
||||
print(CLIENT_NAME)
|
||||
|
||||
for name, cmds in groups:
|
||||
print("")
|
||||
print(name + ":")
|
||||
|
||||
for cmd in cmds:
|
||||
print(" toot", cmd.name.ljust(max_name_len + 2), cmd.description)
|
||||
|
||||
print("")
|
||||
print("To get help for each command run:")
|
||||
|
Loading…
Reference in New Issue
Block a user