tempo is a command-line interface (CLI) application designed to help you quickly manage and use code templates for various purposes, especially useful for competitive programming, project scaffolding, or any repetitive coding tasks.
Ever find yourself copying and pasting the same boilerplate code or utility functions for every new problem (e.g., competitive programming) or project? tempo streamlines this by allowing you to store, manage, and apply your code templates with simple commands.
Core Philosophy:
- User-centric: Easy to use, intuitive commands.
- Portable: Templates stored in a user-specific directory, accessible from anywhere.
- Flexible: Not tied to specific languages or project structures.
- Minimalist: Does one thing well – managing and applying code templates.
- Add Templates:
tempo add <name> <source_file_path>- Store a new template. - Apply Templates:
tempo apply <name> <destination_path> [options]- Create a new file or modify an existing one using a template.- Strategies for existing files: overwrite (
-o), append (-a), prepend (-p).
- Strategies for existing files: overwrite (
- List Templates:
tempo list(orls) - View all your stored templates. - Remove Templates:
tempo remove <name>(orrm) - Delete a template. - Show Template Content:
tempo show <name>- Print a template's content to the console. - Edit Templates:
tempo edit <name>- Open a template in your default editor. - Show Template Path:
tempo path <name>- Display the full path to a stored template file. - Verbose & Quiet Modes: Control output with
-v/--verboseand-q/--quiet. - Force Option:
-f/--forceto bypass confirmations or overwrite. - Manifest-based: Uses a
manifest.tomlfile for robust template metadata management.
- Rust programming language (includes
cargo).
- Clone the repository:
git clone https://github.com/<your_username>/tempo.git cd tempo
- Build and install the binary:
This will install
cargo install --path .tempointo~/.cargo/bin/. Ensure~/.cargo/bin/is in your system'sPATHenvironment variable. The Rust installer usually helps set this up.
For each release, pre-compiled binary is provided for Windows (coming soon for macOS, and Linux) on the GitHub Releases page.
-
Download the appropriate archive or executable for your operating system and architecture from the latest release.
-
Extract the
tempoexecutable if it's in an archive (e.g.,.zipor.tar.gz). -
Place the
tempoexecutable in a directory that is listed in your system'sPATHenvironment variable. This makestempoaccessible from any location in your terminal.Common locations:
- Windows:
- Create a folder like
C:\Program Files\tempoorC:\Users\<YourName>\binand add this folder to your user or systemPATHenvironment variable.
- Create a folder like
How to add a directory to your PATH:
- Windows:
- Search for "environment variables" in the Windows search bar.
- Click on "Edit the system environment variables" (or "Edit environment variables for your account").
- In the System Properties window, click the "Environment Variables..." button.
- Under "User variables" (for just your account) or "System variables" (for all users), find the variable named
Pathand select it. - Click "Edit...".
- Click "New" and add the full path to the directory where you placed
tempo.exe(e.g.,C:\Users\<YourName>\bin). - Click "OK" on all dialogs. You need to open a new Command Prompt or PowerShell window or sometimes you may need to restart the computer for the changes to take effect.
- Windows:
-
Verify installation: Open a new terminal/command prompt and type:
tempo --version
You should see the installed version of
tempo.
All tempo commands follow the pattern tempo [GLOBAL_OPTIONS] <COMMAND> [ARGS].
You can get help for any command by running tempo <COMMAND> --help.
1. Adding a new template:
# Create a Python template file (e.g., my_fast_io.py)
# Content of my_fast_io.py:
# import sys
# def solve():
# input = sys.stdin.readline
# # ... your code ...
# solve()
tempo add py_io ./my_fast_io.py2. Applying a template to a new file:
tempo apply py_io solution.py
# This creates solution.py with the content of the 'py_io' template.3. Applying a template, appending to an existing file:
echo "# My existing code" > main.cpp
tempo add cpp_utils ./my_utils.cpp # Assuming cpp_utils template exists
tempo apply cpp_utils main.cpp -a # Append4. Listing all templates:
tempo list # OR tempo lsExpected output:
Available templates:
--------------------
- py_io (.py)
- cpp_utils (.cpp)
5. Showing a template's content:
tempo show py_io6. Editing a template:
tempo edit py_io
# This will open ~/.config/tempo/templates/py_io.py (or similar) in your default editor.7. Removing a template:
tempo remove py_io
# Or with force:
tempo remove py_io --force8. Getting the stored path of a template:
tempo path py_io-f, --force: Overwrite existing files/templates or skip confirmations.-v, --verbose: Enable verbose output for debugging or more details.-q, --quiet: Suppress informational output (errors will still be shown).-h, --help: Display help information.-V, --version: Display application version.
tempo stores its templates and manifest file in a user-specific configuration directory:
- Linux/macOS[coming soon]:
~/.config/tempo/ - Windows:
%APPDATA%\tempo\(e.g.,C:\Users\<YourName>\AppData\Roaming\tempo\)
The main components are:
~/.config/tempo/templates/: Directory containing the actual template files.~/.config/tempo/manifest.toml: Metadata file for all stored templates.
Contributions are welcome! Please feel free to open an issue or submit a pull request.
This project is licensed under the MIT License.