Group commands contextually in print_help
This commit is contained in:
parent
a57cb5d251
commit
0198bd3af7
2 changed files with 71 additions and 41 deletions
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
|
toot - a Mastodon CLI client
|
||||||
|
|
||||||
Usage:
|
Authentication:
|
||||||
toot login Log into a Mastodon instance
|
toot login Log into a Mastodon instance
|
||||||
toot login_2fa Log in using two factor authentication (experimental)
|
toot login_2fa Log in using two factor authentication (experimental)
|
||||||
toot logout Log out, delete stored access keys
|
toot logout Log out, delete stored access keys
|
||||||
toot auth Show stored credentials
|
toot auth Show stored credentials
|
||||||
|
|
||||||
|
Read:
|
||||||
toot whoami Display logged in user details
|
toot whoami Display logged in user details
|
||||||
toot whois Display user details
|
toot whois Display account details
|
||||||
toot post Post a status text to your timeline
|
|
||||||
toot upload Upload an image or video file
|
|
||||||
toot search Search for users or hashtags
|
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 timeline Show recent items in your public timeline
|
||||||
toot curses An experimental timeline app.
|
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:
|
To get help for each command run:
|
||||||
toot <command> --help
|
toot <command> --help
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ account_arg = (["account"], {
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
COMMANDS = [
|
AUTH_COMMANDS = [
|
||||||
Command(
|
Command(
|
||||||
name="login",
|
name="login",
|
||||||
description="Log into a Mastodon instance",
|
description="Log into a Mastodon instance",
|
||||||
|
@ -57,6 +57,9 @@ COMMANDS = [
|
||||||
arguments=[],
|
arguments=[],
|
||||||
require_auth=False,
|
require_auth=False,
|
||||||
),
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
READ_COMMANDS = [
|
||||||
Command(
|
Command(
|
||||||
name="whoami",
|
name="whoami",
|
||||||
description="Display logged in user details",
|
description="Display logged in user details",
|
||||||
|
@ -65,7 +68,7 @@ COMMANDS = [
|
||||||
),
|
),
|
||||||
Command(
|
Command(
|
||||||
name="whois",
|
name="whois",
|
||||||
description="Display user details",
|
description="Display account details",
|
||||||
arguments=[
|
arguments=[
|
||||||
(["account"], {
|
(["account"], {
|
||||||
"help": "account name or numeric ID"
|
"help": "account name or numeric ID"
|
||||||
|
@ -73,6 +76,36 @@ COMMANDS = [
|
||||||
],
|
],
|
||||||
require_auth=True,
|
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(
|
Command(
|
||||||
name="post",
|
name="post",
|
||||||
description="Post a status text to your timeline",
|
description="Post a status text to your timeline",
|
||||||
|
@ -103,21 +136,9 @@ COMMANDS = [
|
||||||
],
|
],
|
||||||
require_auth=True,
|
require_auth=True,
|
||||||
),
|
),
|
||||||
Command(
|
]
|
||||||
name="search",
|
|
||||||
description="Search for users or hashtags",
|
ACCOUNTS_COMMANDS = [
|
||||||
arguments=[
|
|
||||||
(["query"], {
|
|
||||||
"help": "the search query",
|
|
||||||
}),
|
|
||||||
(["-r", "--resolve"], {
|
|
||||||
"action": 'store_true',
|
|
||||||
"default": False,
|
|
||||||
"help": "Resolve non-local accounts",
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
require_auth=True,
|
|
||||||
),
|
|
||||||
Command(
|
Command(
|
||||||
name="follow",
|
name="follow",
|
||||||
description="Follow an account",
|
description="Follow an account",
|
||||||
|
@ -166,30 +187,29 @@ COMMANDS = [
|
||||||
],
|
],
|
||||||
require_auth=True,
|
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():
|
def print_usage():
|
||||||
print(CLIENT_NAME)
|
|
||||||
print("")
|
|
||||||
print("Usage:")
|
|
||||||
|
|
||||||
max_name_len = max(len(command.name) for command in COMMANDS)
|
max_name_len = max(len(command.name) for command in COMMANDS)
|
||||||
|
|
||||||
for command in COMMANDS:
|
groups = [
|
||||||
print(" toot", command.name.ljust(max_name_len + 2), command.description)
|
("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("")
|
||||||
print("To get help for each command run:")
|
print("To get help for each command run:")
|
||||||
|
|
Loading…
Reference in a new issue