Skip to content

juliusunscripted/rust-project-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rust-project-template

You can use this template to start a new rust project.

Prerequisites

Install rust

Via rustup

Via nix flake

  • (install nix and open nix flake development shell)
  • the git repo contains a flake.nix configuration
  • you can open a dev shell via
     nix develop
  • you can open vscode from inside the nix dev shell via
    • option 1:
       nix develop --command code .
    • option 2:
       ./ctl.sh nix:vscode

Getting started

Create your project

  • create your own repo by using this template
  • rename your package
    • in Cargo.toml
  • rename project variable in src/main.rs for log level configuration

Run your app

Basic run command

  • you can run the code via

     cargo run
  • this template use a rust crate called clap for cli development

  • use cli arguments after two dashes -- when running the program via cargo

     # cli help
     cargo run -- -h
    
     # example run
     cargo run -- --name Julius --count 3

Adjust log levels per module

  • set the environment variable RUST_LOG to configure log levels per module
Set env var inline
RUST_LOG="warn,rust_project_template::example_module::example_submodule=debug" cargo run
Use .env file with bash script

details about ctl.sh script

  • create a file called .env in the root dir of the repo
     RUST_LOG="warn,rust_project_template::example_module::example_submodule=debug"
  • run you app with the following command
     ./ctl.sh cargo:run

About

You can use this template to start a new rust project.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published