1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
//! This library provides access to standard environment variables and logging utilities.
/// Re-exporting the `dotenv` crate for loading environment variables from a `.env` file.
///
/// The `dotenv` crate allows you to load environment variables from a `.env` file into the
/// environment for your application. This is particularly useful for managing configuration
/// settings in a development environment without hardcoding values in your source code.
///
/// # Usage
///
/// Call the `dotenv()` function at the beginning of your application to load the environment
/// variables defined in your `.env` file:
///
/// ```rust
/// use chief::dotenv;
///
/// fn main() {
/// dotenv().ok(); // Load environment variables from the .env file
///
/// // Now you can access variables using chief::env
/// let my_var = chief::env::var("MY_VARIABLE").unwrap_or_default();
/// println!("MY_VARIABLE: {}", my_var);
/// }
/// ```
pub use dotenv; // Keep original without prefix.
/// Re-exporting the `std::env` module for accessing environment variables.
///
/// The `std::env` module provides functions for accessing and manipulating the environment
/// of your Rust application. This can include retrieving environment variables,
/// getting the current working directory, and managing process-specific information.
///
/// # Usage
///
/// You can access environment variables as follows:
///
/// ```rust
/// use chief::env;
///
/// fn main() {
/// // Accessing an environment variable
/// let my_var = env::var("MY_VARIABLE").unwrap_or_else(|_| {
/// eprintln!("MY_VARIABLE is not set.");
/// String::from("default_value")
/// });
///
/// println!("MY_VARIABLE: {}", my_var);
/// }
/// ```
pub use env; // Keep original without prefix.
/// Retrieves the value of an environment variable, providing a default value if the variable is not set.
///
/// The `env_var` function allows you to access environment variables in a safe way,
/// returning a default value if the specified variable is not found. This is useful
/// for providing reasonable defaults in case the environment variable is not defined.
///
/// # Parameters
///
/// - `var_name`: The name of the environment variable to retrieve.
/// - `default`: The default value to return if the environment variable is not set.
///
/// # Returns
///
/// Returns the value of the environment variable as a `String`. If the variable is not set,
/// the provided default value will be returned.
///
/// # Usage
///
/// You can retrieve an environment variable with a default value as follows:
///
/// ```rust
/// use chief::env_var;
///
/// fn main() {
/// // Retrieving an environment variable with a default value
/// let my_var = env_var("MY_VARIABLE", "default_value");
///
/// println!("MY_VARIABLE: {}", my_var);
/// }
/// ```
/// Loads environment variables from a `.env` file into the application's environment.
///
/// The `load_dotenv` function loads environment variables defined in your `.env` file,
/// making them available to your application. This is particularly useful for managing
/// configuration settings without hardcoding sensitive values directly into your source code.
///
/// # Usage
///
/// Call the `load_dotenv` function at the beginning of your application to ensure that
/// the environment variables are loaded before they are accessed:
///
/// ```rust
/// use chief::{load_dotenv, env_var};
///
/// fn main() {
/// // Load environment variables from the .env file
/// load_dotenv();
///
/// // Use env_var or access directly through std::env
/// let my_var = env_var("MY_VARIABLE", "default_value");
/// println!("MY_VARIABLE: {}", my_var);
/// }
/// ```
/// Re-exporting the `log` crate for logging functionalities.
///
/// The `log` crate provides a lightweight logging facade for Rust. Users can set up loggers to capture various
/// log levels and target outputs (e.g., stderr, files, etc.).
///
/// # Usage
///
/// To use the logging features, set the desired log level early in your application, as shown below:
///
/// ```rust
/// use chief::log::{info, warn, error};
///
/// fn main() {
/// info!("This is an info message.");
/// warn!("This is a warning message.");
/// error!("This is an error message.");
/// }
/// ```
///
pub use log;
/// Re-exporting the `simplelog` crate for simplified logging setup.
///
/// The `simplelog` crate provides a simple and straightforward logger implementation.
///
/// # Usage
///
/// You can initialize the logger in your `main` function like this:
///
/// ```rust
/// use chief::log::{info, error}; // Import necessary macros
/// use chief::simplelog::{Config, LevelFilter, SimpleLogger};
///
/// fn main() {
/// SimpleLogger::init(LevelFilter::Info, Config::default()).unwrap(); // Initialize the logger
/// info!("This is an info message.");
/// error!("This is an error message.");
/// }
/// ```
///
pub use simplelog;
use ;
/// ### chief_cli()
///
/// Initializes the Chief command-line interface for managing web applications.
///
/// This function creates a command-line interface using the `clap` library, allowing users
/// to run, test, build, and clean their web applications. It accepts two parameters: the
/// name of the application and its version. The CLI supports subcommands for running the
/// application in different modes (development and production), running tests, building
/// the application (with an option for release mode), and cleaning the project directory.
///
/// **Important:** The `name` parameter passed to `chief_cli` must match the `name` specified
/// in your `Cargo.toml` file. This ensures consistency across your project and allows the
/// CLI to correctly identify the application when commands are executed. For example, if
/// your `Cargo.toml` contains:
///
/// ```toml
/// [package]
/// name = "example"
/// version = "0.1.0"
/// ```
///
/// You should call `chief_cli` with `name` set to `"example"` and `ver` set to `"0.1.0"`.
///
/// When using the `--version` flag in the command line, it will return the output in the format:
/// `<project name> <version>`, reflecting the values provided in the `chief_cli` function.
///
/// ### Parameters
///
/// - `name`: A static string slice representing the name of the application.
/// - `ver`: A static string slice representing the version of the application.
///
/// ### Example
///
/// ```rust
/// 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);
/// }
/// ```
///
/// ### Command Usage
///
/// The following commands are available through the Chief CLI:
///
/// - `run`
/// - `dev`: Runs the application in development mode.
/// - `prod`: Runs the application in production mode.
/// - `test`: Runs the tests for the application.
/// - `build`
/// - `--release`: Builds the application in release mode (optional flag).
/// - `clean`: Cleans the project directory.
/// - `help`: Print this message or the help of the given subcommand(s).
///
/// ### Returns
///
/// This function does not return a value. It executes the specified commands based on user input
/// and handles any errors that may occur during the execution of the commands. If an invalid command
/// is provided, it will print a message indicating that no valid command was provided.
///
/// <small>End Fun Doc</small>