99
1010from operator import attrgetter as _attrgetter
1111
12+ _ALIASES = {
13+ "!" : "set" ,
14+ "@" : "ref" ,
15+ "?" : "help" ,
16+ "&" : "search" ,
17+ "%" : "count" ,
18+ "-" : "note" ,
19+ "\\ " : "notes" ,
20+ }
21+
22+
23+ def _format_alias (name ):
24+ if alias := next ((alias for alias , cmd in _ALIASES .items () if cmd == name ), None ):
25+ return f"(alias: '{ alias } ')"
26+ return ""
27+
1228
1329def _format_lines (lines ):
1430 linesep = "\n " * (_config .linesep + 1 )
@@ -29,8 +45,13 @@ def _ref_parse(ctx, bible_fn, target, term):
2945 return result if result else f"{ term } '{ ' ' .join (target )} ' not found"
3046
3147
48+ def _doc (hdoc , name ):
49+ if hdoc and name :
50+ return hdoc .replace ("@alias" , _format_alias (name ))
51+
52+
3253def help (ctx , * args ):
33- """Prints this help."""
54+ """Prints this help. @alias """
3455 if args :
3556 match args :
3657 case ["help" , * sub_command ]:
@@ -40,17 +61,18 @@ def help(ctx, *args):
4061 sys .modules [__name__ ], name
4162 ), f"command '{ name } ' not found"
4263 if target := getattr (sys .modules [__name__ ], name ).__doc__ :
43- print (target )
64+ print (_doc ( target , name ) )
4465 case [name , sub_command ]:
4566 module = _command .eval_module (name )
46- print (getattr (module , sub_command ).__doc__ )
67+ if target := getattr (module , sub_command ).__doc__ :
68+ print (_doc (target , name ))
4769 case _:
4870 print (
4971 "Error: You must use help for command and one sub-command only.\n \n help <command> [<sub-command>]"
5072 )
5173 else :
5274 methods = sorted (
53- f"{ method .__name__ :<20} { method .__doc__ .splitlines ()[0 ]} "
75+ f"{ method .__name__ :<20} { _doc ( method .__doc__ .splitlines ()[0 ], method . __name__ ) } "
5476 for method in [getattr (ctx .module , name ) for name in ctx .methods ]
5577 )
5678
@@ -59,7 +81,7 @@ def help(ctx, *args):
5981
6082
6183def set (ctx , * args ):
62- """Configure a sub-command with a new value.
84+ """Configure a sub-command with a new value. @alias
6385
6486 set <config> <value>
6587
@@ -69,7 +91,7 @@ def set(ctx, *args):
6991
7092
7193def ref (ctx , * args ):
72- """Search a reference(s) by chapters and verses.
94+ """Search a reference(s) by chapters and verses. @alias
7395
7496 ref <book> [<chapter>[:<verse[-verse]>]]
7597
@@ -85,7 +107,7 @@ def ref(ctx, *args):
85107
86108
87109def search (ctx , * args ):
88- """Search one or more words.
110+ """Search one or more words. @alias
89111
90112 search <word [word2 [...]]>
91113
@@ -101,7 +123,7 @@ def search(ctx, *args):
101123
102124
103125def count (ctx , * args ):
104- """Count how much words.
126+ """Count how much words. @alias
105127
106128 count <word [word2 [...]]>
107129
@@ -164,16 +186,17 @@ def blb(ctx, *args):
164186
165187
166188def notes (ctx , * args ):
167- """List all notes."""
189+ """List all notes. @alias"""
190+ assert not args , "you should use only notes"
168191 return _format_lines (ctx .notes ) if ctx .notes else None
169192
170193
171194def note (ctx , * args ):
172- """Adds a new note.
195+ """Adds a new note. @alias
173196
174197 notes <string>"""
175198 target = " " .join (args )
176199
177- assert target , "you should use notes <string>"
200+ assert target , "you should use note <string>"
178201 ctx .add_note (target )
179202 return None
0 commit comments