Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In PR #3 , we were parsing a file every time when the user tries to autocomplete --script-args command, it is very ineffective as we have to access the file frequently, the reason why we can't use this approach is well explained in PR #3 .
I developed a new code which doesn't waste its time on I/O operations and instead the new code is directly connected to the kernel.
Working of my code
The
script-args.db
file is a db file which contains all the available --script-args options along with script-name.$NMAPDIR/scripts/script-args/
which will be storing all the files required by the autocomplete feature.script-args.db
is located in"$NMAPDIR/scripts/script-args/script-args.db"
.On executing the above script, it parses the
script-args.db
and creates empty directories for all scripts which are present inscript-args.db
file. The empty directories are created insidescripts/script-args/
folder and name of these empty folders is same as the name of the available scripts.Each folder also contains empty files named with the options available for that script.Let me illustrate this with an example.
Assume there are only two lines in the script-args.db file
On executing the script.sh file, it extracts the script-name and the available options for every script.
So the directory structure would be something like this,
So, here I'm using the name of the files to autocomplete --script-args . This is a way faster than the previous method as there are no I/O operations involved and it is directly associated with the kernel itself.