slither
slither copied to clipboard
slither: implement shell completions with `shtab`
These can be generated by running e.g. slither --print-completion zsh and installed as usual.
Closes #2055
[!IMPORTANT]
Auto Review Skipped
Draft detected.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository.To trigger a single review, invoke the
@coderabbitai reviewcommand.
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>.Generate unit-tests for this file.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit tests for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai generate interesting stats about this repository from git and render them as a table.@coderabbitai show all the console.log statements in this repository.@coderabbitai read src/utils.ts and generate unit tests.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (invoked as PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger a review. This is useful when automatic reviews are disabled for the repository.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai helpto get help.
Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
CodeRabbit Configration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - The JSON schema for the configuration file is available here.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json
CodeRabbit Discord Community
Join our Discord Community to get help, request features, and share feedback.
Sample Homebrew patch to generate and install these new completions (keep this in mind as well):
diff --git a/Formula/s/slither-analyzer.rb b/Formula/s/slither-analyzer.rb
index d8e1b9a97cb..6ac645f6c3d 100644
--- a/Formula/s/slither-analyzer.rb
+++ b/Formula/s/slither-analyzer.rb
@@ -7,7 +7,7 @@ class SlitherAnalyzer < Formula
sha256 "d01ad88a7fc9581f717859c66d01ef1658ba49505c60e89d5cf38ce6a7f4cdff"
license "AGPL-3.0-only"
revision 1
- head "https://github.com/crytic/slither.git", branch: "master"
+ head "https://github.com/crytic/slither.git", branch: "dev-autocompletion"
bottle do
rebuild 3
@@ -179,6 +179,11 @@ class SlitherAnalyzer < Formula
sha256 "0210b2668f24c078307260bf88bdac9d6f1093635df5123789bfee4d8d7fc8e7"
end
+ resource "shtab" do
+ url "https://files.pythonhosted.org/packages/14/0e/ce211daf7b28fe685b1c9a21d943b3a1c4f300a07e6c59d8765c5f22eb06/shtab-1.6.5.tar.gz"
+ sha256 "cf4ab120183e84cce041abeb6f620f9560739741dfc31dd466315550c08be9ec"
+ end
+
resource "toolz" do
url "https://files.pythonhosted.org/packages/3e/bf/5e12db234df984f6df3c7f12f1428aa680ba4e101f63f4b8b3f9e8d2e617/toolz-0.12.1.tar.gz"
sha256 "ecca342664893f177a13dac0e6b41cbd8ac25a358e5f215316d43e2100224f4d"
@@ -223,6 +228,18 @@ class SlitherAnalyzer < Formula
site_packages = Language::Python.site_packages("python3.12")
paths = %w[crytic-compile solc-select].map { |p| Formula[p].opt_libexec/site_packages }
(libexec/site_packages/"homebrew-deps.pth").write paths.join("\n")
+
+ bin.each_child do |tool|
+ # simil requires optional dependency
+ next if tool == bin/"slither-simil"
+
+ generate_completions_from_executable(
+ tool,
+ shell_parameter_format: "--print-completion=",
+ shells: [:bash, :zsh],
+ base_name: tool.basename.to_s
+ )
+ end
end
test do
HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source --HEAD slither-analyzer
Is this ready to go?
@0xalpharush I think so! some more testing would be appreciated though