tps (template-project-starter) is a lightweight, fast Rust-based project starter that scaffolds new projects using customizable JSON templates. With TPS, you can quickly set up a project structure for multiple programming languages by defining your own templates.
- Custom Templates: Define JSON templates for your projects. Each template specifies the folder structure and starter files.
- Cross-Platform: Automatically uses platform-appropriate defaults for storing templates.
- Placeholder Replacement: Automatically replaces placeholders like {{project_name}} in file contents.
- Multi-Language Support: Example templates for Rust, Python, Node.js, Java, Go, C, TypeScript, and JavaScript.
This project uses the following Rust crates:
- clap: For parsing command-line arguments
- serde and serde_json: For JSOn serialization and deserialization
- dirs: For safe static initialization of global variables
-
Clone the Repository:
git clone https://github.com/stigsec/Template-Project-Starter.git cd Template-Project-Starter
-
Build the Project:
cargo build --release
The compiled binary will be located in
target/release/tps
tps takes two arguments: the template file and the project name.
tps rust.json rustProject
tps searcher for templates in the directory specified by the TPS_PATH
environment variable. If TPS_PATH
is not set, tps falls back to a default directory:
- On Windows: Uses the local data directory.
- On Linux/macOS: Uses the configuration directory.
Add the following line to your shell configuration file (e.g., ~/.bashrc
or ~/.zshrc
):
export TPS_PATH="$HOME/.config/projectTemplates"
After updating your shell configuration file, reload it with:
source ~/.bashrc
$env:TPS_PATH = "C:\\Path\\To\\projectTemplates"
Templates are defined as JSON files. Below is an example for a Rust project:
{
"name": "rust-basic",
"folders": ["src", "tests"],
"files": {
"Cargo.toml": "[package]\nname = \"{{project_name}}\"\nversion = \"0.1.0\"\nedition = \"2021\"",
"src/main.rs": "fn main() {\n println!(\"Hello, world!\");\n}"
}
}
Place your custom templates in the directory specified by TPS_PATH
(or the default directory)
This project is licensed under the GNU General Public License v3.0. See the LICENSE file for more details.
Developed by stigsec.