From baf5229f4473166225b34b5716d4368623a179e0 Mon Sep 17 00:00:00 2001 From: Ritchie Mwewa <74001397+rly0nheart@users.noreply.github.com> Date: Thu, 8 May 2025 03:48:16 +0200 Subject: [PATCH] Added a CLI with code highlighting, and table display for the results... also, code got refactored --- README.md | 72 +++++++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index c95a84e..bc2805b 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@


Python SDK and Command-Line Utility for Searchcode.
Search 75 billion lines of code from 40 million projects

---- - ```commandline searchcode --help ``` @@ -17,8 +15,6 @@ for result in search.results: print(result) ``` ---- - ## Installation ```bash @@ -56,6 +52,12 @@ Queries the code index and returns at most 100 results. ### Code Search Without Filters +#### CLI + +```commandline +searchcode test +``` + #### SDK ```python @@ -68,16 +70,16 @@ for result in search.results: print(result) ``` -#### CLI - -```commandline -searchcode test -``` - --- ### Filter by Language (Java and JavaScript) +#### CLI + +````commandline +searchcode test --languages java,javascript +```` + #### SDK ```python @@ -90,16 +92,16 @@ for result in search.results: print(result.language) ``` -#### CLI - -````commandline -searchcode test --languages java,javascript -```` - ___ ### Filter by Source (BitBucket and CodePlex) +#### CLI + +```commandline +searchcode test --sources bitbucket,codeplex +``` + #### SDK ```python @@ -112,16 +114,16 @@ for result in search.results: print(result.filename) ``` +___ + +### Filter by Lines of Code (Between 500 and 1000) + #### CLI ```commandline -searchcode test --sources bitbucket,codeplex +searchcode test --lines-of-code-gt 500 --lines-of-code-lt 1000 ``` -___ - -### Filter by Lines of Code (Between 500 and 1000) - #### SDK ```python @@ -135,16 +137,16 @@ for result in search.results: print(result) ``` +___ + +### With Callback Function (JSONP only) + #### CLI ```commandline -searchcode test --lines-of-code-gt 500 --lines-of-code-lt 1000 +searchcode test --callback myCallback ``` -___ - -### With Callback Function (JSONP only) - #### SDK ```python @@ -155,11 +157,7 @@ search = sc.search(query="test", callback="myCallback") print(search) ``` -#### CLI - -```commandline -searchcode test --callback myCallback -``` +` ### Response Attribute Definitions @@ -198,6 +196,12 @@ ___ Returns the raw data from a code file given the code id which can be found as the `id` in a code search result. +#### CLI + +```commandline +searchode code 4061576 +``` + #### SDK #### Params @@ -213,11 +217,7 @@ code = sc.code(4061576) print(code) ``` -#### CLI - -```commandline -searchode code 4061576 -``` +--- ## About Searchcode