Group commands contextually in print_help - toot - Unnamed repository; edit this file 'description' to name the repository.
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit 0198bd3af7cbbf367dc6d8152bc8bf535c096cfd
(DIR) parent a57cb5d2519923c48763de31a1edbb81104f2845
(HTM) Author: Ivan Habunek <ivan@habunek.com>
Date: Wed, 26 Apr 2017 12:11:52 +0200
Group commands contextually in print_help
Diffstat:
README.rst | 20 +++++++++++++++-----
toot/console.py | 88 +++++++++++++++++++------------
2 files changed, 69 insertions(+), 39 deletions(-)
---
(DIR) diff --git a/README.rst b/README.rst
@@ -36,20 +36,30 @@ 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 whois Display account details
+ toot search Search for users or hashtags
+ 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
- toot search Search for users or hashtags
+
+ Accounts:
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.
+ 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
(DIR) diff --git a/toot/console.py b/toot/console.py
@@ -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"
@@ -74,6 +77,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",
arguments=[
@@ -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():
+ max_name_len = max(len(command.name) for command in COMMANDS)
+
+ groups = [
+ ("Authentication", AUTH_COMMANDS),
+ ("Read", READ_COMMANDS),
+ ("Post", POST_COMMANDS),
+ ("Accounts", ACCOUNTS_COMMANDS),
+ ]
+
print(CLIENT_NAME)
- print("")
- print("Usage:")
- max_name_len = max(len(command.name) for command in COMMANDS)
+ for name, cmds in groups:
+ print("")
+ print(name + ":")
- for command in COMMANDS:
- print(" toot", command.name.ljust(max_name_len + 2), command.description)
+ for cmd in cmds:
+ print(" toot", cmd.name.ljust(max_name_len + 2), cmd.description)
print("")
print("To get help for each command run:")