package xonshimport ()// Snippet creates the xonsh completion script.func ( *cobra.Command) string { := strings.Replace(.Name(), "-", "__", -1)returnfmt.Sprintf(`from xonsh.completers.completer import add_one_completerfrom xonsh.completers.tools import contextual_command_completer@contextual_command_completerdef _%v_completer(context): """carapace completer for %v""" if context.completing_command('%v'): from json import loads from xonsh.completers.tools import sub_proc_get_output, RichCompletion def fix_prefix(s): """quick fix for partially quoted prefix completion ('prefix',<TAB>)""" return s.translate(str.maketrans('', '', '\'"')) output, _ = sub_proc_get_output( '%v', '_carapace', 'xonsh', *[a.value for a in context.args], fix_prefix(context.prefix) ) try: result = {RichCompletion(c["Value"], display=c["Display"], description=c["Description"], prefix_len=len(context.raw_prefix), append_closing_quote=False, style=c["Style"]) for c in loads(output)} except: result = {} if len(result) == 0: result = {RichCompletion(context.prefix, display=context.prefix, description='', prefix_len=len(context.raw_prefix), append_closing_quote=False)} return resultadd_one_completer('%v', _%v_completer, 'start')`, , .Name(), .Name(), uid.Executable(), .Name(), )}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.