Document kitty @
This commit is contained in:
@@ -376,7 +376,7 @@ def print_help_for_seq(seq, usage, message, appname):
|
||||
print_help_for_seq.allow_pager = True
|
||||
|
||||
|
||||
def seq_as_rst(seq, usage, message, appname):
|
||||
def seq_as_rst(seq, usage, message, appname, heading_char='-'):
|
||||
import textwrap
|
||||
blocks = []
|
||||
a = blocks.append
|
||||
@@ -393,7 +393,7 @@ def seq_as_rst(seq, usage, message, appname):
|
||||
a('')
|
||||
if seq:
|
||||
a('Options')
|
||||
a('----------------')
|
||||
a(heading_char * 30)
|
||||
for opt in seq:
|
||||
if isinstance(opt, str):
|
||||
a(opt)
|
||||
@@ -558,11 +558,11 @@ def options_spec():
|
||||
return options_spec.ans
|
||||
|
||||
|
||||
def option_spec_as_rst(ospec=options_spec, usage=None, message=None, appname=None):
|
||||
def option_spec_as_rst(ospec=options_spec, usage=None, message=None, appname=None, heading_char='-'):
|
||||
options = parse_option_spec(ospec())
|
||||
seq, disabled = options
|
||||
oc = Options(seq, usage, message, appname)
|
||||
return seq_as_rst(oc.seq, oc.usage, oc.message, oc.appname)
|
||||
return seq_as_rst(oc.seq, oc.usage, oc.message, oc.appname, heading_char=heading_char)
|
||||
|
||||
|
||||
def parse_args(args=None, ospec=options_spec, usage=None, message=None, appname=None):
|
||||
|
||||
@@ -635,8 +635,12 @@ def set_background_opacity(boss, window, payload):
|
||||
cmap = {v.name: v for v in globals().values() if hasattr(v, 'is_cmd')}
|
||||
|
||||
|
||||
def cli_params_for(func):
|
||||
return (func.options_spec or '\n').format, func.argspec, func.desc, '{} @ {}'.format(appname, func.name)
|
||||
|
||||
|
||||
def parse_subcommand_cli(func, args):
|
||||
opts, items = parse_args(args[1:], (func.options_spec or '\n').format, func.argspec, func.desc, '{} @ {}'.format(appname, func.name))
|
||||
opts, items = parse_args(args[1:], *cli_params_for(func))
|
||||
if func.args_count is not None and func.args_count != len(items):
|
||||
if func.args_count == 0:
|
||||
raise SystemExit('Unknown extra argument(s) supplied to {}'.format(func.name))
|
||||
|
||||
@@ -33,7 +33,7 @@ def handle_cmd(boss, window, cmd):
|
||||
global_options_spec = partial('''\
|
||||
--to
|
||||
An address for the kitty instance to control. Corresponds to the address
|
||||
given to the kitty instance via the --listen-on option. If not specified,
|
||||
given to the kitty instance via the :option:`kitty --listen-on` option. If not specified,
|
||||
messages are sent to the controlling terminal for this process, i.e. they
|
||||
will only work if this process is run within an existing kitty window.
|
||||
'''.format, appname=appname)
|
||||
@@ -84,18 +84,19 @@ def do_io(to, send, no_response):
|
||||
|
||||
|
||||
all_commands = tuple(sorted(cmap))
|
||||
cli_msg = (
|
||||
'Control {appname} by sending it commands. Add'
|
||||
' :italic:`allow_remote_control yes` to |kitty.conf| for this'
|
||||
' to work.'
|
||||
).format(appname=appname)
|
||||
|
||||
|
||||
def parse_rc_args(args):
|
||||
cmds = (' :green:`{}`\n {}'.format(cmap[c].name, cmap[c].short_desc) for c in all_commands)
|
||||
msg = (
|
||||
'Control {appname} by sending it commands. Add'
|
||||
' :italic:`allow_remote_control yes` to |kitty.conf| for this'
|
||||
' to work.\n\n:title:`Commands`:\n{cmds}\n\n'
|
||||
'You can get help for each individual command by using:\n'
|
||||
'{appname} @ :italic:`command` -h'
|
||||
).format(appname=appname, cmds='\n'.join(cmds))
|
||||
|
||||
msg = cli_msg + (
|
||||
'\n\n:title:`Commands`:\n{cmds}\n\n'
|
||||
'You can get help for each individual command by using:\n'
|
||||
'{appname} @ :italic:`command` -h').format(appname=appname, cmds='\n'.join(cmds))
|
||||
return parse_args(args[1:], global_options_spec, 'command ...', msg, '{} @'.format(appname))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user