Created
June 23, 2020 01:52
-
-
Save bhank/cf8d163b404ba2e23c29fefd2ca45111 to your computer and use it in GitHub Desktop.
Some clink autocompletions for Anaconda
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local w = require('tables').wrap | |
local path = require('path') | |
-- https://stackoverflow.com/questions/59788504/how-to-use-the-clink-lua-api | |
-- https://github.com/vladimir-kotikov/clink-completions/blob/master/chocolatey.lua | |
local parser = clink.arg.new_parser | |
local envs = function (token) | |
envdir = clink.get_env('conda_prefix_1') | |
if envdir == nil then | |
envdir = clink.get_env('conda_prefix') | |
end | |
return w(clink.find_dirs(envdir..'/envs/*')) | |
:filter(function(dir) | |
return path.is_real_dir(dir) and clink.is_match(token, dir) | |
end) | |
end | |
local conda_parser = parser( | |
{ | |
"clean", | |
"config", | |
"create" .. parser( | |
{}, | |
-- "-h", "--help", | |
"--clone" .. parser({envs}), | |
"-n" | |
-- "-p", | |
-- "-c", | |
-- "--use-local", | |
-- "--override-channels", | |
-- "--repodata-fn", | |
-- "--strict-channel-priority", | |
-- "--no-channel-priority", | |
-- "--no-deps", | |
-- "--only-deps", | |
-- "--no-pin", | |
-- "--copy", | |
-- "--no-shortcuts", | |
-- "-C", | |
-- "-k", | |
-- "--offline", | |
-- "-d", | |
-- "--json", | |
-- "-q", | |
-- "-v", | |
-- "-y", | |
-- "--download-only", | |
-- "--show-channel-urls", | |
-- "--file", | |
-- "--no-default-packages", | |
-- "--dev" | |
), | |
"help", | |
"info", | |
"init", | |
"install", | |
"list", | |
"package", | |
"remove", | |
"uninstall", | |
"run", | |
"search", | |
"update", | |
"upgrade", | |
"build", | |
"convert", | |
"debug", | |
"develop", | |
"env" .. parser( | |
{ | |
"create", | |
"export", | |
"list", | |
"remove" .. parser( | |
{"--name"}, | |
"-h", "--help", | |
"-n" .. parser({envs}), | |
"--name" .. parser({envs}), | |
"-p", "--prefix", | |
"-d", "--dry-run", | |
"--json", | |
"-q", "--quiet", | |
"-v", "--verbose", | |
"-y", "--yes" | |
), | |
"update", | |
"config" | |
} | |
), | |
"index", | |
"inspect", | |
"metapackage", | |
"render", | |
"server", | |
"skeleton", | |
"verify", | |
"activate" .. parser( | |
{envs, "base"}, | |
"-h", "--help", | |
"--stack", | |
"--no-stack" | |
) | |
} | |
) | |
clink.arg.register_parser("conda", conda_parser) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment