latte: A developer's best friend
latte is a command-line tool designed to help Python developers analyze their code quickly and easily. It provides several useful commands for code inspection and package management.
Installation
- Ensure you have Python 3 installed on your system.
- Clone the repository or download the
latte_main.pyfile. - (Optional) Create an alias for easy access:
- Open your shell configuration file (
.zshrcor.bashrc):bash nano ~/.zshrc # For zsh # or nano ~/.bashrc # For bash - Add this line at the end of the file:
bash alias latte='python3 /path/to/your/latte_main.py' - Save the file and reload your shell configuration:
bash source ~/.zshrc # For zsh # or source ~/.bashrc # For bash
- Open your shell configuration file (
Usage
- Open a terminal and navigate to the directory containing
latte_main.py. - Run the script:
bash python3 latte_main.py(Or simply typelatteif you've set up the alias) - When prompted, enter the full path to the Python file you want to analyze.
- Use the available commands to analyze your code.
Available Commands
ln: Returns the number of lines of code in the filexn: Returns the number of variables in the codepi: Installs all the packages imported in the filefn: Returns the number of functions in the filehelp: Displays the list of available commandsexit: Exits the program
Command Details
ln (Line Number)
This command counts and displays the total number of lines in your Python file.
Example:
latte> ln
Number of lines: 50
xn (Variable Count)
This command counts and displays the number of variables defined in your Python file.
Example:
latte> xn
Number of variables: 10
pi (Package Install)
This command identifies all the packages imported in your Python file and attempts to install them using pip.
Example:
latte> pi
Installed 3 packages.
fn (Function Count)
This command counts and displays the number of functions defined in your Python file.
Example:
latte> fn
Number of functions: 5
help
Displays the list of available commands and their brief descriptions.
exit
Exits the Latte tool.
Example Session
Welcome to Latte!
Enter the name of the Python file you're editing: /path/to/your/script.py
Type 'help' for a list of commands.
latte> ln
Number of lines: 100
latte> xn
Number of variables: 15
latte> fn
Number of functions: 7
latte> pi
Installed 2 packages.
latte> exit
Notes
- Ensure you have the necessary permissions to install packages when using the
picommand. - The tool currently analyzes one file at a time. To analyze a different file, you need to restart the tool.
- Make sure to provide the full path to the Python file you want to analyze when prompted.
Log in or sign up for Devpost to join the conversation.