New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add completion for nmap #6873
add completion for nmap #6873
Conversation
can someone explain the failed test? Is there something I can do? |
- still uses grep - slower but more detailed output
Great, nmap completions were also on my todo list 👍
This project is experimenting with GitHub Actions for CI but it does not work well at the moment. Ignore it for now. I have a few comments regarding your completion: You use Whenever you need to supply a file argument, you use For the |
@exploide: Thanks for the recommendations, I implemented everything you suggested. |
I just added the completion for |
Looks good overall. When you only want to complete non-file arguments, use
We already have netcat completions in nc.fish. This contains mostly the same completions you have in If you prefer to use the |
There are dozens of netcat-implementations and all of them are different. The typical ones are nc.openbsd or nc.traditional which are symlinked to nc. However, one often finds Busybox to be symlinked to nc or ncat symlinked to nc… Of course, I see your point and one could try to extract all common nc-completions which is included in all others and they make their extensions. However, as there are so many nc-implementations, I think one will last with a really small common set… |
This was a bug… I corrected it. |
If it is a small finite number of possible arguments, yes, you could do something like
Yes, I share your observation. Though, the current The idea was, that This is similar to what you propose with:
Just that I would dispatch everything within Both would work. Actually I start to like your idea. But one problem could be that sometimes there is just a |
|
Nah, I was talking about the completion file associated to some command that is wrapped in this case. Anyway, let's do it as you proposed. I like your idea more. When the cases I mentioned occur, we can still incorporate that version of nc in I only have minor review comments on your For the execution option When an argument is required, explicitly use |
Then, you can change the existing # There a several different implementations of netcat.
# Let's use the version string to tell them apart
# and load to right set of completions.
set -l netcat (nc --version 2>&1 | string collect)
# Nmap Ncat
string match -q -e -- Ncat "$netcat" && complete -c nc -w ncat Further implementations of netcat can easily be added in the future :) And I think we are done. |
- implement the most common netcat variants on Linux - nc.openbsd - nc.traditional - nc tries to guess which netcat is currently used
- use file-completion on exec and sh-exec - deny file-completion for allow and deny
I think using |
I did not imagine it's that bad...
Looks great. I think that should work most of the time :) Thanks! |
I have another improvements. The first is just the replacement of |
I think caching these is a good idea. But I'm not sure whether it is expected behaviour for a completion script to set global variables. I would leave that question open for a fish maintainer. |
The problem with caching is then invalidation - if you have a long-running session that nmap gets upgraded underneath, you end up with incomplete lists in some sessions and that can cause confusion. We do it elsewhere it is kicked off in the background so as not to block the completions, and then regenerated every 5 minutes - see share/functions/__fish_print_packages.fish. In this case I wouldn't bother. |
ok, I added a timestamp, it gets renewed every 5 minutes
I think we do not need that much overhead here. The completion needs only 500ms on my computer, so the caching is somewhat a luxury problem ;) |
I think the file nc.traditional should be named nc.traditional.fish |
Quite right, fixed in 021679b |
Description
This is a completion for the well-known
nmap
tool.TODOs: