All Rust projects can follow this pattern:
- Create a new repo using Rust New Project Template: https://github.com/noahgift/rust-new-project-template
- Create a new Codespaces and use it
- Use
main.rs
to call handle CLI and uselib.rs
to handle logic and importclap
inCargo.toml
as shown in this project. - Use `cargo init --name 'hello' or whatever you want to call your project.
- Put your "ideas" in as comments in rust to seed GitHub Copilot, i.e //build add function
- Run
make format
i.e.cargo format
- Run
make lint
i.e.cargo clippy --quiet
- Run project:
cargo run -- --help
- Push your changes to allow GitHub Actions to:
format
check,lint
check, and other actions like binary deploy.
This pattern is a new emerging pattern and is ideal for systems programming in Rust.
A good starting point for a new Rust project
To run: cargo run -- marco --name "Marco"
Be careful to use the NAME of the project in the Cargo.toml
to call lib.rs
as in:
[package]
name = "hello"
For example, see the name hello
is invoked alongside marco_polo
which is in lib.rs
.
fn main() {
let args = Cli::parse();
match args.command {
Some(Commands::Marco { name }) => {
println!("{}", hello::marco_polo(&name));
}
None => println!("No command was used"),
}
}