-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
271 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
Command Line Interface (CLI) | ||
---------------------------- | ||
|
||
Run the CLI using the following syntax: | ||
|
||
.. code-block:: shell | ||
code [OPTIONS] COMMAND [ARGS]... | ||
Options | ||
~~~~~~~ | ||
|
||
- ``-v, --verbose INTEGER``: Set verbosity level (0, 1, or 2). | ||
- ``-q, --quiet``: Enable quiet mode. | ||
- ``--version``: Display version information. | ||
|
||
Commands | ||
~~~~~~~~ | ||
|
||
1. **inspect**: Inspect a package and display a file-language map. | ||
|
||
.. code-block:: shell | ||
code inspect <path> | ||
**Example** | ||
|
||
.. code-block:: shell | ||
$ code inspect src/codergpt/ | ||
Inspecting the code. | ||
File Language | ||
------------------------------------------ ---------- | ||
src/codergpt/constants.py Python | ||
src/codergpt/__init__.py Python | ||
src/codergpt/cli.py Python | ||
... | ||
2. **explain**: Explain a specific function or class within a package. | ||
|
||
.. code-block:: shell | ||
code explain <path> [--function <function_name>] [--classname <class_name>] | ||
**Example** | ||
|
||
.. code-block:: shell | ||
$ code explain src/codergpt/explainer/explainer.py --function explain | ||
Explanation for the code: | ||
This code defines a method called `explain` that takes in three parameters... | ||
3. **comment**: Add comments to the code in a package. The user has the choice to overwrite the file or create a new one. | ||
|
||
.. code-block:: shell | ||
code comment <path> [--overwrite/--no-overwrite] | ||
**Example** | ||
|
||
- Let's consider a python file `greetings.py`: | ||
|
||
.. code-block:: python | ||
def greet(name): | ||
return f"Hello, {name}!" | ||
if __name__ == "__main__": | ||
user_name = "Alice" | ||
print(greet(user_name)) | ||
.. code-block:: shell | ||
$ code comment greetings.py --overwrite | ||
results in .... | ||
|
||
.. code-block:: python | ||
def greet(name): | ||
""" | ||
Generates a greeting message for the given name. | ||
... | ||
""" | ||
4. **optimize**: Optimizes and adds comments to the code in a package. The user has the choice to overwrite the file or create a new one. | ||
|
||
.. code-block:: shell | ||
code optimize <path> [--overwrite/--no-overwrite] | ||
**Example** | ||
|
||
- Let's consider a python file `example.py`: | ||
|
||
.. code-block:: python | ||
# example.py | ||
def calculate_sum(numbers): | ||
result = 0 | ||
for number in numbers: | ||
result += number | ||
return result | ||
class MathOperations: | ||
def multiply(self, a, b): | ||
answer = 0 | ||
for i in range(b): | ||
answer += a | ||
return answer | ||
.. code-block:: shell | ||
$ code optimize example.py --overwrite | ||
results in .... | ||
|
||
.. code-block:: python | ||
""" | ||
Optimized and Documented Code: | ||
... | ||
""" | ||
Development | ||
----------- | ||
|
||
The CLI is built using Python and the `click` library. Below is an example of how to define a new command: | ||
|
||
.. code-block:: python | ||
import click | ||
from codergpt import CoderGPT | ||
coder = CoderGPT() | ||
@click.command() | ||
@click.argument('path', type=click.Path(exists=True)) | ||
def new_command(path): | ||
# Command logic here | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.. _codergpt-cli: | ||
|
||
CoderGPT CLI | ||
============ | ||
|
||
Description | ||
----------- | ||
|
||
CoderGPT CLI is a command line interface, a state-of-the-art code | ||
generation/modifying tool. It allows developers to interact with the | ||
CoderGPT functionalities directly from the terminal, streamlining their | ||
workflow and enhancing code. The underlying engine that facilitates | ||
the code enhancement and modification is `langchain | ||
<https://github.com/langchain-ai/langchain>`_. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Installation | ||
------------ | ||
|
||
To use the CoderGPT CLI, clone the repository and install the required dependencies. | ||
|
||
.. code-block:: shell | ||
pip install codergpt | ||
The most recent code and data can be installed directly from GitHub with: | ||
|
||
.. code-block:: shell | ||
pip install git+https://github.com/hrshdhgd/CoderGPT.git | ||
To install in development mode (using `poetry`), use the following: | ||
|
||
.. code-block:: shell | ||
$ git clone git+https://github.com/hrshdhgd/CoderGPT.git | ||
$ cd CoderGPT | ||
$ poetry install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters