picocli icon indicating copy to clipboard operation
picocli copied to clipboard

Support clink completion in DOS Command Prompt

Open remkop opened this issue 5 years ago • 0 comments

The clink project allows TAB completion in the Command Prompt shell. The clink documentation indicates it should be possible to customize this:

Clink can be extended through its Lua API which allows easy creation context sensitive match generators, prompt filtering, and more. More details can be found in Clink's documentation which can be found here.

The above documentation link unfortunately does not show any documentation, but there is a separate clink-completions project that has Lua scripts for completing some well-known command line utilities.

Also:

  • https://rstforums.com/forum/topic/63715-clink/
  • https://github.com/mridgers/clink/blob/298113a61272afa3f646a912c97e2ce34da67597/docs/clink.md#file-locations
  • https://github.com/vladimir-kotikov/clink-completions/issues/48
  • https://trzeci.eu/my-setup-for-conemu-and-clink/

Investigate how much effort it would be to generate Lua scripts for completing picocli-based commands on DOS prompt systems that have clink installed.

Example script:

--package.path = debug.getinfo(1, "S").source:match[[^@?(.*[\/])[^\/]-$]] .."modules/?.lua;".. package.path
--local matchers = require('matchers')
local parser = clink.arg.new_parser
local nested_parser = parser(
    {
        "add" .. parser({},
            "-n", "--dry-run",
            "-v", "--verbose",
            "-f", "--force",
            "-i", "--interactive",
            "-p", "--patch",
            "-e", "--edit",
            "-u", "--update",
            "-A", "--all",
            "--no-all",
            "--ignore-removal",
            "--no-ignore-removal",
            "-N", "--intent-to-add",
            "--refresh",
            "--ignore-errors",
            "--ignore-missing"
            ),
        "apply" .. parser(
            "--stat",
            "--numstat",
            "--summary",
            "--check",
            "--index",
            "--cached",
            "-3", "--3way",
            "--build-fake-ancestor=",
            "-R", "--reverse",
            "--reject",
            "-z",
            "-p",
            "-C",
            "--unidiff-zero",
            "--apply",
            "--no-add",
            "--allow-binary-replacement", "--binary",
            "--exclude=",
            "--include=",
            "--ignore-space-change", "--ignore-whitespace",
            "--whitespace=",
            "--inaccurate-eof",
            "-v", "--verbose",
            "--recount",
            "--directory="
            ),
        "branch" .. parser(
            "-v", "--verbose",
            "-q", "--quiet",
            "-t", "--track",
            "--set-upstream",
            "-u", "--set-upstream-to",
            "--unset-upstream",
            "--color",
            "-r", "--remotes",
            "--contains" ,
            "--abbrev",
            "-a", "--all",
--            "-d" .. parser({branches}):loop(1),
--            "--delete" .. parser({branches}):loop(1),
--            "-D" .. parser({branches}):loop(1),
            "-m", "--move",
            "-M",
            "--list",
            "-l", "--create-reflog",
            "--edit-description",
            "-f", "--force",
            "--no-merged",
            "--merged",
            "--column"
        ),
        "clone" .. parser(
            "--template",
            "-l", "--local",
            "-s", "--shared",
            "--no-hardlinks",
            "-q", "--quiet",
            "-n", "--no-checkout",
            "--bare",
            "--mirror",
            "-o", "--origin",
            "-b", "--branch",
            "-u", "--upload-pack",
            "--reference",
            "--dissociate",
            "--separate-git-dir",
            "--depth",
            "--single-branch", "--no-single-branch",
            "--no-tags",
            "--recurse-submodules", "--shallow-submodules", "--no-shallow-submodules",
            "--jobs"
        ),
        "column",
        "commit" .. parser(
            "-a", "--all",
            "-p", "--patch",
            "-C", "--reuse-message=",
            "-c", "--reedit-message=",
            "--fixup=",
            "--squash=",
            "--reset-author",
            "--short",
            "--branch",
            "--porcelain",
            "--long",
            "-z",
            "--null",
            "-F", "--file=",
            "--author=",
            "--date=",
            "-m", "--message=",
            "-t", "--template=",
            "-s", "--signoff",
            "-n", "--no-verify",
            "--allow-empty",
            "--allow-empty-message",
            "--cleanup", -- .. parser({"strip", "whitespace", "verbatim", "default"}),
            "-e", "--edit",
            "--no-edit",
            "--amend",
            "--no-post-rewrite",
            "-i", "--include",
            "-o", "--only",
            "-u", "--untracked-files", "--untracked-files=", -- .. parser({"no", "normal", "all"}),
            "-v", "--verbose",
            "-q", "--quiet",
            "--dry-run",
            "--status",
            "--no-status",
            "-S", "--gpg-sign", "--gpg-sign=",
            "--"
        ),
        "commit-tree",
        "fetch-pack",
        "remote"..parser({
            "add" ..parser(
                "-t"..parser({branches}),
                "-m",
                "-f",
                "--mirror",
                "--tags", "--no-tags"
            ),
            "rename"..parser({remotes}),
            "remove"..parser({remotes}),
            "rm"..parser({remotes}),
            "set-head"..parser({remotes}, {branches},
                "-a", "--auto",
                "-d", "--delete"
            ),
            "set-branches"..parser("--add", {remotes}, {branches}),
            "set-url"..parser(
                "--add"..parser("--push", {remotes}),
                "--delete"..parser("--push", {remotes})
            ),
            "get-url"..parser({remotes}, "--push", "--all"),
            "show"..parser("-n", {remotes}),
            "prune"..parser("-n", "--dry-run", {remotes}),
            "update"..parser({remotes}, "-p", "--prune")
            }, "-v", "--verbose"),
        "write-tree",
    },
    "--version",
    "--help",
    "-c",
    "--exec-path",
    "--html-path",
    "--bare",
    "--git-dir=",
    "--work-tree=",
    "--namespace="
)

clink.arg.register_parser("nested", nested_parser)

remkop avatar Jan 20 '20 06:01 remkop