Crates.io | chief |
lib.rs | chief |
version | 0.5.0 |
source | src |
created_at | 2024-10-19 12:50:10.258962 |
updated_at | 2024-11-04 11:48:48.076655 |
description | A Development Tools |
homepage | https://github.com/dr-montasir/chief |
repository | https://github.com/dr-montasir/chief |
max_upload_size | |
id | 1415341 |
size | 42,290 |
Chief Development Tools provides versatile functionalities for managing web applications. Depending on your requirements, you can choose between different installation methods. Whether you want to utilize the command-line interface (CLI) for seamless application management or integrate logging and environment variable handling into your project, Chief offers flexible options tailored to your development needs. This empowers developers to enhance their workflow and streamline application processes efficiently.
log
crate for logging at various levels and configure with the simplelog
crate for easy setup.If your primary focus is to run commands (such as run dev
, run prod
) and execute tests without needing to manage environment variables or logging, you can install Chief directly using:
cargo install chief
This command installs the CLI tool, enabling you to run your application and execute tests easily.
For developers who only need to manage environment variables and logging functionalities, you can add Chief as a dependency to your project without the CLI commands using:
To include Environment Variable Management and Dotenv:
cargo add chief
Or add chief
to your Cargo.toml
file:
[dependencies]
chief = "MAJOR.MINOR.PATCH" # Replace with the latest version
To build the Chief
Development Tools from source, follow these commands:
git clone https://github.com/dr-montasir/chief.git
cd chief
cargo build --release
The following subcommands are available in the CLI:
run
: Runs the application.
run dev
: Runs the application in development mode.run prod
: Runs the application in production mode.test
: Runs the tests for the application.
build
: Compiles the application.
build --release
: Compiles the application in release mode for optimized performance.clean
: Cleans the target directory, removing all generated artifacts.
help
: Print this message or the help of the given subcommand(s).
> chief -h
A CLI for managing web applications
Usage: chief [COMMAND]
Commands:
run Runs the application
test Runs the tests
build Builds the application
clean Cleans the project
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
The chief_cli
function serves as the core entry point for the Chief CLI application. It initializes the command-line interface and processes user commands efficiently. By encapsulating the command-handling logic, it allows developers to focus on building their applications without worrying about the underlying command processing mechanics. This function enhances the usability of the CLI, making it easier for developers to manage their applications through intuitive commands.
use chief::chief_cli;
fn main() {
let app_name = "example"; // Any project name can be here.
let app_version = "0.1.0";
chief_cli(app_name, app_version);
}
To run the application in development mode:
chief run dev
To run the application in production mode:
chief run prod
To execute tests:
chief test
Chief Development Tools uses the log
crate to facilitate logging functionalities. You can set up logging simply in your main application:
use chief::log::{info, warn, error};
use chief::simplelog::{Config, LevelFilter, SimpleLogger};
fn main() {
// Initialize the SimpleLogger
SimpleLogger::init(LevelFilter::Info, Config::default()).unwrap();
info!("This is an info message.");
warn!("This is a warning message.");
error!("This is an error message.");
}
Accessing environment variables in your application can be done using the chief::{dotenv, env}
modules. Here is a simple way to get an environment variable:
# .env file
MY_ENV_VARIABLE=my_variable
use chief::{dotenv, env};
fn main() {
dotenv().ok();
if let Ok(value) = env::var("MY_ENV_VARIABLE") {
println!("My environment variable is: {}", value);
} else {
println!("Environment variable not set.");
}
}
// Output:
// My environment variable is: my_variable
This project is licensed under either of the following licenses:
You may choose either license for your purposes.
Contributions are welcome! Please feel free to submit a pull request or open an issue for any feature requests or bug reports.