Comments (12)
Info Needed
If someone can share the output from these commands, I can probably make a completion script, even though I've never used Nuke.Build.
nuke :complete "nuke "
nuke :complete "nuke --"
nuke :complete "nuke c"
P.S. The docs for Nuke.Build seem to be missing a lot of important info (prerequisites, CLI reference, uninstall, to name a few topics). That's making it unrealistically complicated for me to figure out how to even get it installed and working. Otherwise I'd be able to quickly make and test a completion script.
P.P.S. @Matze693 What problem(s) did you run into? It looks like it's probably just a matter of running nuke :complete THE_SANITIZED_COMMAND_LINE
and returning a table of words from that.
Rough Guess At A Prototype
The following MIGHT work, or it MIGHT go horribly awry. I cannot test it. But it's a rough guess at a script.
Note that this only generates completions. It doesn't apply input line coloring -- that would require a more sophisticated approach, and first it would be necessary to get basic completions working.
-- This script generates completions for Nuke.Build.
--
-- However, this does not apply input line coloring; that would require a more
-- complicated approach in order to collect and cache available completions in
-- the background, in order to apply coloring.
if true then
print("THIS IS A TEST SCRIPT AND PROBABLY DOES NOT WORK YET.")
print()
print("If you want to try experimenting with it, delete these lines from the script.")
return
end
if (clink.version_encoded or 0) < 10040019 then
print("nuke.lua requires a newer version of Clink; please upgrade.")
return
end
local function sanitize_line(line_state)
local text = ""
local function sanitize_word(index, info)
local end_offset = info.offset + info.length - 1
if end_offset < info.offset and index == line_state:getwordcount() then
end_offset = line_state:getcursor() - 1
end
local word = line_state:getline():sub(info.offset, end_offset)
word = word:gsub('"', '\\"')
return word
end
for i = 1, line_state:getwordcount() do
local info = line_state:getwordinfo(i)
local word
if info.alias then
word = "nuke"
elseif not info.redir then
word = sanitize_word(i, info)
end
if word then
if #text > 0 then
text = text .. " "
end
text = text .. word
end
end
return text
end
local function nuke_complete(line_state, builder, filter)
local matches = {}
-- Run 'nuke :complete' to get completions.
local nuke = '"nuke"'
local commandline = sanitize_line(line_state)
local command = '2>nul '..nuke..' :complete "'..commandline..'"'
local f = io.popen(command)
if f then
for line in f:lines() do
line = line:gsub('"', '')
if line ~= "" and line:find(filter) then
-- Add non-blank words to the list of completion matches.
table.insert(matches, line)
end
end
f:close()
end
-- Mark the matches volatile even when generation was skipped due to
-- running in a coroutine. Otherwise it'll never run it in the main
-- coroutine, either.
builder:setvolatile()
-- Enable quoting.
builder:setforcequoting()
return matches
end
local function nuke_complete_flags(word, index, line_state, builder) -- luacheck: no unused args
-- Filter completions to only include flags.
return nuke_complete(line_state, builder, '^%-')
end
local function nuke_complete_nonflags(word, index, line_state, builder) -- luacheck: no unused args
-- Filter completions to exclude flags.
return nuke_complete(line_state, builder, '^[^-]')
end
clink.argmatcher("nuke")
:addflags(nuke_complete_flags)
:addarg(nuke_complete_nonflags)
:loop()
from clink-completions.
I just had the time to test it and I can report that it works fine as well for me.
Thanks @chrisant996 ❤️
from clink-completions.
Seems similar to winget
's integrated completion. You could try starting with a copy of the completions\winget.lua
script and modifying it.
from clink-completions.
Thank you for your quick reply, I will try.
from clink-completions.
@Matze693 Any success?
from clink-completions.
@Otiel nope, Clink is not as easy as I thought 🙈 no success.
from clink-completions.
@chrisant996 awesome, thanks a lot for your support. I will check your script when I'm back in the office and send you the output of the commands.
from clink-completions.
@chrisant996 here are the outputs when using in repo https://github.com/nuke-build/nuke
$ nuke :complete "nuke "
Announce
Announce-Discord
Announce-Mastodon
Announce-Slack
Announce-Twitter
Changelog
Checkout-External-Repositories
Clean
Compile
Create-GitHub-Release
Delete-Packages
Download-Licenses
Generate-Global-Solution
Generate-Public-Api
Generate-Tools
Hotfix
Install
Install-Fonts
Milestone
Pack
Publish
References
Release
Release-Image
Report-Coverage
Report-Duplicates
Report-Issues
Restore
Run-Target-In-Docker-Image-Test
Sign-Packages
Test
Update-Contributors
Update-Stargazers
--auto-stash
--codecov-token
--configuration
--continue
--discord-webhook
--feedz-nuget-api-key
--github-release-github-token
--help
--host
--ignore-failed-sources
--major
--mastodon-access-token
--no-logo
--partition
--plan
--profile
--public-nuget-api-key
--root
--signpath-api-token
--signpath-organization-id
--signpath-policy-slug
--signpath-project-slug
--skip
--slack-webhook
--solution
--target
--test-degree-of-parallelism
--twitter-access-token
--twitter-access-token-secret
--twitter-consumer-key
--twitter-consumer-secret
--use-https
--verbosity
$ nuke :complete "nuke --"
--auto-stash
--codecov-token
--configuration
--continue
--discord-webhook
--feedz-nuget-api-key
--github-release-github-token
--help
--host
--ignore-failed-sources
--major
--mastodon-access-token
--no-logo
--partition
--plan
--profile
--public-nuget-api-key
--root
--signpath-api-token
--signpath-organization-id
--signpath-policy-slug
--signpath-project-slug
--skip
--slack-webhook
--solution
--target
--test-degree-of-parallelism
--twitter-access-token
--twitter-access-token-secret
--twitter-consumer-key
--twitter-consumer-secret
--use-https
--verbosity
$ nuke :complete "nuke c"
changelog
checkout-external-repositories
clean
compile
create-github-release
from clink-completions.
@chrisant996 I tested also your script but no success. I'm using clink within https://cmder.app/ and for this I changed back to deprecated mechanism to register a parser.
local parser = clink.arg.new_parser
local nuke_parser = parser():set_arguments(nuke_complete_nonflags):set_flags(nuke_complete_flags)
clink.arg.register_parser("nuke", remote_parser)
from clink-completions.
@chrisant996 I tested also your script but no success.
Can you share more about "no success"?
With the sample output you shared, I've been able to make a simple nuke.cmd script that prints the same output (thus simulating the real nuke program).
For me, the script works perfectly as-is, except for a one-line mistake that accidentally prevents flags from working.
So the "no success" report is interesting, and I need more information to be able to solve whatever "no success" means.
I'm using clink within https://cmder.app/ and for this I changed back to deprecated mechanism to register a parser.
What version of Clink are you using?
What version of Cmder are you using?
It sounds like maybe you are using a very old version of Cmder and Clink?
from clink-completions.
Commit b444e8c adds completions for Nuke.Build.
But @Matze693 you experienced "no success" with the script, so there might be something else interfering on your computer.
from clink-completions.
@chrisant996 I updated all tools (clink and cmder) and now your script works perfectly. Thank you so much for your support 👍🏼
from clink-completions.
Related Issues (20)
- Unwanted behaviour for `adb` and `scrcpy` completions. HOT 6
- git.lua:155: attempt to call upvalue 'w' (a nil value) HOT 8
- Run git pull on script folders after update HOT 3
- Error when completing ssh HOT 3
- Improve winget completion HOT 9
- openssl.lua:1179: attempt to compare number with string HOT 1
- Error "module 'path' not found" on fresh install. HOT 8
- Sudo Clink version mismatch HOT 6
- Winget completion throws error HOT 8
- git add completions are git root relative instead of cwd relative HOT 2
- Git add tries to add already added (renamed/moved) file HOT 2
- RFE: add completions for ping HOT 10
- Bug: completions from known_hosts for ssh and ping on non-default port HOT 5
- The new git_prompt.lua in 0.4.9 breaks custom non-cmder prompt HOT 6
- Add completions for arduino-cli HOT 1
- How to let 'git add' completion non-recursive HOT 7
- Add completions for go and rust tools
- Test error HOT 7
- Update docs HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clink-completions.