Ever wrote code so trash it burnt your eyes? ๐ฅ๐ Fear not! Diamondify is here to rescue your retinas and make your code efficient and well-commented!
Before you embark on your Diamondifying Journey, you'll need to set up your secret weapon: the OpenAI API key!
Choose your operating system and follow the instructions:
๐ป Windows
- Open the Start menu and search for "Environment Variables"
- Click on "Edit the system environment variables"
- Click the "Environment Variables" button
- Under "System variables", click "New"
- Set the variable name as
OPENAI_API_KEY
- Set the variable value as your OpenAI API key
- Click "OK" to save
Alternatively, you can use the command prompt:
setx OPENAI_API_KEY "your-api-key-here"
Remember to restart your command prompt after setting the variable!
๐ macOS and Linux
- Open Terminal
- Edit your shell configuration file (e.g.,
~/.bash_profile
,~/.zshrc
) - Add the following line:
export OPENAI_API_KEY="your-api-key-here"```
- Save the file and run:
source ~/.bash_profile
or ( if you are using Zsh)
source ~/.zshrc
Now that you're all set up, let's make some code efficient!
python diamondify.py [-h] (-f FILE | -d DIRECTORY) [-o OUTPUT] -m MODEL
-h
,--help
: Show the help message and exit-f FILE
,--file FILE
: Input file to process-d DIRECTORY
,--directory DIRECTORY
: Input directory to process-o OUTPUT
,--output OUTPUT
: Output directory (default: ./output)-m MODEL
,--model MODEL
: Model to use for processing (default: gpt-4o)
Clean, and improve the code of a single file ( btw supports any programming language):
python main.py -f ugly_code.py -m gpt-4o
Improve the code of a whole directory:
python main.py -d messy_project -o shiny_project -m gpt-4o
Note - By default all the code will be saved in a new directory called as output inside the working directory of the terminal
Sit back and witness Diamondify transform your code from cluttered to clean and efficient! ๐งนโจ
Diamondify doesn't just make your code prettier - it enhances its efficiency and readability by:
- Optimizing algorithms and data structures ๐ง
- Adding clear, concise comments to functions and code blocks ๐
- Improving variable naming for better comprehension ๐ท๏ธ
- Refactoring complex logic into more manageable chunks ๐งฉ
- Suggesting best practices and design patterns where applicable ๐
Remember, with great power comes great responsibility. Use Diamondify to learn and improve your coding skills, not just as a quick fix! ๐
If you encounter any problems or have questions about the improvements Diamondify suggests, feel free to open an issue. We're here to help you understand and elevate your code! ๐
Now go forth and enhance your code with Diamondify! ๐๐