Kickstart your Copper development by generating a new project structure using our predefined templates. This approach sets up a basic or full project skeleton, allowing you to focus on building your application logic faster.
Before you begin, ensure you have the following installed:
-
Rust and Cargo: If you don't have them, install Rustup (which includes Rust and Cargo):
curl --proto '=https' --tlsv1.2 -sSf [https://sh.rustup.rs](https://sh.rustup.rs) | sh # Follow the on-screen instructions
-
cargo-generate: This Cargo subcommand is used to scaffold projects from templates. Install it using Cargo:cargo install cargo-generate
You can generate a new Copper project using the cargo generate command along with specific template details.
Available templates:
cu_project: A single-crate project for quick experiments.cu_full: A multi-crate workspace withapps/andcomponents/(payloads, sources, tasks, sinks).
Example: Generating a Workspace or Single-Crate Project
-
Navigate to the Templates Directory: The templates are located within a
templatessubdirectory relative to this README (adjust the path if necessary).cd templates -
Run
cargo generate: Execute one of the following commands to generate a workspace namedtest_workspaceor a single-crate project namedtest_projectin the parent directory (./relative totemplates, which means the same directory where thetemplatesfolder resides).# Workspace template cargo +stable generate \ --path cu_full \ --name test_workspace \ --destination . \ --define copper_source=local \ --define copper_root_path=../.. # Single-crate project template cargo +stable generate \ --path cu_project \ --name test_project \ --destination . \ --define copper_source=local \ --define copper_root_path=../..
Explanation of Options:
+stable: Ensures you use the stable Rust toolchain (recommended for consistency).--path cu_full(or-p cu_full): Specifies the path to the workspace template to use. The path is relative to your current directory (templates).--path cu_project(or-p cu_project): Specifies the path to the single-crate template to use. The path is relative to your current directory (templates).--name test_workspaceor--name test_project: Sets the name of the new project directory and often influences internal project names.--destination .: Specifies where the generated project directory should be created. Here,.means the current directory.--define <key>=<value>(or-d <key>=<value>): Sets template variables. These are used by the template during generation.copper_source=local: Indicates using a local version of Copper.copper_root_path=../..: Specifies the relative path from the generated project's location back to the root of thecopper-rsrepository. Adjust this path if yourcopper-rslocation differs.
Note: If you omit the
--nameor--defineflags,cargo-generatewill interactively prompt you for values like the project name and any required template variables (likecopper_root_path). Using the flags provides these values directly.You can also use
cunewas an alias forcargo generate:cargo cunew .Or use the
templates/justfilefor the standard names:just gen-workspace just gen-project
-
Change into the new workspace or project directory: For the workspace template:
cd ../test_workspace # Adjust path if you used a different destination
For the single-crate template:
cd ../test_project # Adjust path if you used a different destination
The workspace template includes
apps/andcomponents/(payloads, sources, tasks, sinks) so it scales beyond a single crate. The single-crate template keeps everything undersrc/. -
Run the project using Cargo: For the workspace template (main app):
cargo run -p test-workspace
Or run the demo app:
cargo run -p test-workspace-demo
Or run from the main app directory:
cd ../test_workspace/apps/test_workspace cargo runFor the single-crate template:
cargo run
The generated project includes helper commands in its justfile:
just log: Extract and view structured logs generated by your Copper application.just cl: Extract CopperLists (sequences of operations) from the application's log output.just rcfg: Generate a.dotfile representing the application's execution Directed Acyclic Graph (DAG). You can use tools like Graphviz to visualize this file (e.g.,dot -Tpng graph.dot -o graph.png).
Set APP_NAME=test-workspace-demo APP_DIR=test_workspace-demo to target the demo app (for example, APP_NAME=test-workspace-demo APP_DIR=test_workspace-demo just log).