From 0f83747da73e9d6bfef91d4db47c6ca05d8acd76 Mon Sep 17 00:00:00 2001 From: Chris Antos Date: Thu, 5 Sep 2024 10:13:27 -0700 Subject: [PATCH] Add completions for `where`. --- completions/where.lua | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 completions/where.lua diff --git a/completions/where.lua b/completions/where.lua new file mode 100644 index 0000000..4470a44 --- /dev/null +++ b/completions/where.lua @@ -0,0 +1,34 @@ +require('arghelper') + +local dir_matcher = clink.argmatcher():addarg(clink.dirmatches) + +-- luacheck: push +-- luacheck: no max line length +local flag_def_table = { + {"/r", dir_matcher, " dir", "Recursively searches and displays the files that match the given pattern starting from the specified directory"}, + {"/q", "Returns only the exit code, without displaying the list of matched files. (Quiet mode)"}, + {"/f", "Displays the matched filename in double quotes"}, + {"/t", "Displays the file size, last modified date and time for all matched files"}, + {"/?", "Displays help message"}, +} +-- luacheck: pop + +local flags = {} +for _,f in ipairs(flag_def_table) do + if f[3] then + table.insert(flags, { f[1]..f[2], f[3], f[4] }) + if f[1]:upper() ~= f[1] then + table.insert(flags, { hide=true, f[1]:upper()..f[2], f[3], f[4] }) + end + else + table.insert(flags, { f[1], f[2] }) + if f[1]:upper() ~= f[1] then + table.insert(flags, { hide=true, f[1]:upper(), f[2] }) + end + end +end + +-- luacheck: no max line length +clink.argmatcher("where") +:setflagsanywhere(false) +:_addexflags(flags)