As a developer, I constantly search for tools that can optimize my workflow and simplify my tasks. That’s why I developed GPT-CLI, a command line interface designed to harness the power of OpenAI’s GPT, the world’s most advanced language model. My project’s goal is to make GPT’s incredible capabilities more accessible and easily integrated into your workflow, directly from the command line.

Getting Started with GPT-CLI

To utilize GPT-CLI, you’ll need an OpenAI API key. Registering and creating an API key is simple, and once you have it, you can create an appSettings.json file in your current working directory containing the following contents:

1
2
3
4
5
{
  "OpenAI": {
    "api-key": "sk-your-api-key-here"
  }
}

Alternatively, you can also use the api-key command line parameter:

1
gpt api-key "sk-your-api-key-here" prompt "generate a hello world python script" > hello.py

GPT-CLI is a .NET 7 standalone console application, so you won’t need to install the .NET CLI or runtime in your environment.

Discovering GPT-CLI’s Features

GPT-CLI enables you to access GPT’s impressive language comprehension and generation abilities directly from your terminal. With GPT-CLI, you can accomplish tasks like generating code, composing content, and more, all by simply executing commands.

For instance, you could generate a bash script for “Hello, World!” using the following command:

1
gpt prompt "create a bash Hello World script" > hello.sh

GPT-CLI’s potential extends even further. You can pipe GPT commands to other commands or back to GPT itself, creating powerful and dynamic workflows.

I created GPT-CLI to optimize my own workflow, and the results were astonishing. I’ve already employed it to refactor my code, produce documentation, and even process text in combination with other command line tools like grep, awk, and sed.

More examples

Refactor a Python function for improved readability:

1
gpt prompt "refactor this Python function for better readability" < original_code.py

Generate comments in existing javascript:

1
cat file.js | gpt prompt "reproduce this function verbatim, but add comments throughout" > file.js

Generate a SQL query based off a table definition

1
2
cat tableDefinition.sql | gpt prompt "create a SQL query to select all columns from the users \
 table where the email column contains 'example.com'" > query.sql

Translate English text to French

1
gpt prompt "translate the following English text to French" < english_text.txt > french_translation.txt

Create a list of blog post ideas with summaries

1
2
gpt prompt "generate a list of 10 blog post ideas about machine learning" | gpt \
prompt "write a quick summary about each of these ideas"

Use awk to extract specific columns from a CSV file and generate a Python script to process the data:

1
2
awk -F, '{print $1 "," $3}' input_data.csv | gpt prompt "create a Python script to \
process the following CSV data" > process_data.py

Filter a list of email addresses and generate a regular expression to match them:

1
2
cat email_list.txt | grep "@example.com" | gpt prompt "generate a regular expression \
to match these email addresses" > regex.txt

These examples demonstrate the versatility of GPT-CLI and how it can be used for various tasks across different domains.

GPT-CLI has rapidly become an essential tool in my development arsenal. The possibilities are only limited by my imagination and ability to prompt and chain together commands.

Conclusion

Developing GPT-CLI has enabled me to integrate GPT into my workflow, streamline my tasks, and unleash my creative potential. In fact, I even used GPT-CLI to generate this very blog post!

If you’re a developer seeking to harness the power of OpenAI’s GPT, I highly recommend trying GPT-CLI. It’s a game-changing tool that will revolutionize the way you work.