diff --git a/docs/_advanced/tips/shell-completion.md b/docs/_advanced/tips/shell-completion.md index fcc791b0..b564fed3 100644 --- a/docs/_advanced/tips/shell-completion.md +++ b/docs/_advanced/tips/shell-completion.md @@ -12,16 +12,46 @@ To enable auto-completion for Zsh, run the following command to generate the com ```bash noir --generate-completion zsh +# #compdef noir +# _arguments \ +# .... ``` Then, move the generated script to your Zsh completions directory, typically `~/.zsh/completion/`. If this directory does not exist, you may need to create it. Ensure the script is named `_noir` to follow Zsh's naming convention for completion scripts. +```bash +noir --generate-completion zsh > ~/.zsh/completion/_noir +``` + ## Bash completion For Bash, generate the completion script by running: ```bash noir --generate-completion bash +# _noir_completions() { +# local cur prev opts +# .... +``` + +After generating the script, move it to the appropriate directory for Bash completions. This location can vary depending on your operating system and Bash configuration, but a common path is `/etc/bash_completion.d/` for system-wide availability, or `~/.local/share/bash-completion/completions/` for a single user. Ensure the script is executable and sourced in your Bash profile. + +```bash +noir --generate-completion bash > ~/.local/share/bash-completion/completions/noir ``` -After generating the script, move it to the appropriate directory for Bash completions. This location can vary depending on your operating system and Bash configuration, but a common path is `/etc/bash_completion.d/` for system-wide availability, or `~/.local/share/bash-completion/completions/` for a single user. Ensure the script is executable and sourced in your Bash profile. \ No newline at end of file +## Fish completion + +For Fish, generate the completion script by running: + +```bash +noir --generate-completion fish +# function __fish_noir_needs_command +# .... +``` + +After generating the script, move it to the Fish completions directory, typically `~/.config/fish/completions/.` If this directory does not exist, you may need to create it. Ensure the script is named noir.fish to follow Fish's naming convention for completion scripts. + +```bash +noir --generate-completion fish > ~/.config/fish/completions/noir.fish +``` \ No newline at end of file diff --git a/docs/_includes/usage.md b/docs/_includes/usage.md index 4883c74b..89e49b91 100644 --- a/docs/_includes/usage.md +++ b/docs/_includes/usage.md @@ -19,7 +19,7 @@ FLAGS: --set-pvalue-json VALUE Specifies the value of the identified parameter for JSON data --set-pvalue-path VALUE Specifies the value of the identified parameter for path parameters --status-codes Display HTTP status codes for discovered endpoints - --exclude-codes Exclude specific HTTP status code + --exclude-codes 404,500 Exclude specific HTTP response codes (comma-separated) --include-path Include file path in the plain result --no-color Disable color output --no-log Displaying only the results @@ -48,7 +48,7 @@ FLAGS: CONFIG: --config-file ./config.yaml Specify the path to a configuration file in YAML format --concurrency 100 Set concurrency - --generate-completion zsh Generate Zsh/Bash completion script + --generate-completion zsh Generate Zsh/Bash/Fish completion script DEBUG: -d, --debug Show debug messages diff --git a/src/completions.cr b/src/completions.cr index 795b6c5b..7de15984 100644 --- a/src/completions.cr +++ b/src/completions.cr @@ -105,4 +105,52 @@ _noir_completions() { complete -F _noir_completions noir SCRIPT +end + +def generate_fish_completion_script + <<-SCRIPT +function __fish_noir_needs_command + set -l cmd (commandline -opc) + if test (count $cmd) -eq 1 + return 0 + end + return 1 +end + +complete -c noir -n '__fish_noir_needs_command' -a '-b' -d 'Set base path' +complete -c noir -n '__fish_noir_needs_command' -a '-u' -d 'Set base URL for endpoints' +complete -c noir -n '__fish_noir_needs_command' -a '-f' -d 'Set output format' +complete -c noir -n '__fish_noir_needs_command' -a '-o' -d 'Write result to file' +complete -c noir -n '__fish_noir_needs_command' -a '--set-pvalue' -d 'Specifies the value of the identified parameter' +complete -c noir -n '__fish_noir_needs_command' -a '--set-pvalue-header' -d 'Specifies the value of the identified parameter for headers' +complete -c noir -n '__fish_noir_needs_command' -a '--set-pvalue-cookie' -d 'Specifies the value of the identified parameter for cookies' +complete -c noir -n '__fish_noir_needs_command' -a '--set-pvalue-query' -d 'Specifies the value of the identified parameter for query parameters' +complete -c noir -n '__fish_noir_needs_command' -a '--set-pvalue-form' -d 'Specifies the value of the identified parameter for form data' +complete -c noir -n '__fish_noir_needs_command' -a '--set-pvalue-json' -d 'Specifies the value of the identified parameter for JSON data' +complete -c noir -n '__fish_noir_needs_command' -a '--set-pvalue-path' -d 'Specifies the value of the identified parameter for path parameters' +complete -c noir -n '__fish_noir_needs_command' -a '--status-codes' -d 'Display HTTP status codes for discovered endpoints' +complete -c noir -n '__fish_noir_needs_command' -a '--exclude-codes' -d 'Exclude specific HTTP response codes (comma-separated)' +complete -c noir -n '__fish_noir_needs_command' -a '--include-path' -d 'Include file path in the plain result' +complete -c noir -n '__fish_noir_needs_command' -a '--no-color' -d 'Disable color output' +complete -c noir -n '__fish_noir_needs_command' -a '--no-log' -d 'Displaying only the results' +complete -c noir -n '__fish_noir_needs_command' -a '-T' -d 'Activates all taggers for full analysis coverage' +complete -c noir -n '__fish_noir_needs_command' -a '--use-taggers' -d 'Activates specific taggers' +complete -c noir -n '__fish_noir_needs_command' -a '--list-taggers' -d 'Lists all available taggers' +complete -c noir -n '__fish_noir_needs_command' -a '--send-req' -d 'Send results to a web request' +complete -c noir -n '__fish_noir_needs_command' -a '--send-proxy' -d 'Send results to a web request via an HTTP proxy' +complete -c noir -n '__fish_noir_needs_command' -a '--send-es' -d 'Send results to Elasticsearch' +complete -c noir -n '__fish_noir_needs_command' -a '--with-headers' -d 'Add custom headers to be included in the delivery' +complete -c noir -n '__fish_noir_needs_command' -a '--use-matchers' -d 'Send URLs that match specific conditions to the Deliver' +complete -c noir -n '__fish_noir_needs_command' -a '--use-filters' -d 'Exclude URLs that match specified conditions and send the rest to Deliver' +complete -c noir -n '__fish_noir_needs_command' -a '--diff-path' -d 'Specify the path to the old version of the source code for comparison' +complete -c noir -n '__fish_noir_needs_command' -a '-t' -d 'Specify the technologies to use' +complete -c noir -n '__fish_noir_needs_command' -a '--exclude-techs' -d 'Specify the technologies to be excluded' +complete -c noir -n '__fish_noir_needs_command' -a '--list-techs' -d 'Show all technologies' +complete -c noir -n '__fish_noir_needs_command' -a '--config-file' -d 'Specify the path to a configuration file in YAML format' +complete -c noir -n '__fish_noir_needs_command' -a '--concurrency' -d 'Set concurrency' +complete -c noir -n '__fish_noir_needs_command' -a '-d' -d 'Show debug messages' +complete -c noir -n '__fish_noir_needs_command' -a '-v' -d 'Show version' +complete -c noir -n '__fish_noir_needs_command' -a '--build-info' -d 'Show version and Build info' +complete -c noir -n '__fish_noir_needs_command' -a '-h' -d 'Show help' +SCRIPT end \ No newline at end of file diff --git a/src/options.cr b/src/options.cr index 37b46e78..5ab16cc2 100644 --- a/src/options.cr +++ b/src/options.cr @@ -122,7 +122,7 @@ def run_options_parser parser.separator "\n CONFIG:".colorize(:blue) parser.on "--config-file ./config.yaml", "Specify the path to a configuration file in YAML format" { |var| noir_options["config_file"] = YAML::Any.new(var) } parser.on "--concurrency 100", "Set concurrency" { |var| noir_options["concurrency"] = YAML::Any.new(var) } - parser.on "--generate-completion zsh", "Generate Zsh/Bash completion script" do |var| + parser.on "--generate-completion zsh", "Generate Zsh/Bash/Fish completion script" do |var| case var when "zsh" puts generate_zsh_completion_script @@ -130,10 +130,14 @@ def run_options_parser when "bash" puts generate_bash_completion_script STDERR.puts "\n> Instructions: Copy the content above and save it in the .bashrc file as noir.".colorize(:yellow) + when "fish" + puts generate_fish_completion_script + STDERR.puts "\n> Instructions: Copy the content above and save it in the fish-completion directory as noir.fish".colorize(:yellow) else puts "ERROR: Invalid completion type.".colorize(:yellow) puts "e.g., noir --generate-completion zsh" puts "e.g., noir --generate-completion bash" + puts "e.g., noir --generate-completion fish" end exit