From b62540abd7626fb27a847d75b3aa870ea524192b Mon Sep 17 00:00:00 2001 From: skn437 Date: Sat, 13 Jul 2024 23:48:51 +0600 Subject: [PATCH] Added args module --- .editorconfig | 13 +- .gitignore | 10 +- .idea/.gitignore | 8 - .idea/codeStyles/Project.xml | 275 ------------------- .idea/codeStyles/codeStyleConfig.xml | 5 - .idea/inspectionProfiles/Project_Default.xml | 5 - .idea/jsonSchemas.xml | 25 -- .idea/ktlint-plugin.xml | 6 - .idea/material_theme_project_new.xml | 12 - .idea/misc.xml | 23 -- .idea/modules.xml | 8 - .idea/prettier.xml | 9 - .idea/skn-rust-utils.iml | 12 - .idea/vcs.xml | 6 - .prettierignore | 10 +- Cargo.toml | 4 +- README.md | 32 ++- src/args.rs | 25 ++ src/lib.rs | 18 +- 19 files changed, 95 insertions(+), 411 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/codeStyles/Project.xml delete mode 100644 .idea/codeStyles/codeStyleConfig.xml delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/jsonSchemas.xml delete mode 100644 .idea/ktlint-plugin.xml delete mode 100644 .idea/material_theme_project_new.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/prettier.xml delete mode 100644 .idea/skn-rust-utils.iml delete mode 100644 .idea/vcs.xml create mode 100644 src/args.rs diff --git a/.editorconfig b/.editorconfig index 9ad499c..7e475ce 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,6 +11,7 @@ insert_final_newline = true # (Please don't specify an indent_size here; that has too many unintended consequences.) # Kotlin files +# noinspection EditorConfigKeyCorrectness [*.{kt,kts}] indent_size = 2 @@ -52,8 +53,8 @@ indent_size = 2 [*.{html,css,sass,scss,md,mdx}] indent_size = 2 -# JSON, TOML, XML, YAML files -[*.{json,toml,xml,yaml}] +# IML, JSON, Properties, TOML, XML, YAML files +[*.{iml,json,properties,toml,xml,yaml}] indent_size = 2 # Shell Script, Text & Log files @@ -68,6 +69,14 @@ indent_size = 2 [*.{py,ipynb}] indent_size = 2 +# Ignore files +[.*ignore] +indent_size = 2 + +# Docker files +[Dockerfile] +indent_size = 2 + # C, C++ files [*.{c,cpp}] indent_size = 2 diff --git a/.gitignore b/.gitignore index 05fbb18..cd37b11 100644 --- a/.gitignore +++ b/.gitignore @@ -111,6 +111,10 @@ wwwroot *.nupkg packages -# VS Code/JetBrains IDE -!icon.tar.gz -!*-settings.zip +# JetBrains IDE +.idea +!.idea/icon.tar.gz +!.idea/*-settings.zip +*.iws +*.iml +*.ipr diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b8..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml deleted file mode 100644 index f810d93..0000000 --- a/.idea/codeStyles/Project.xml +++ /dev/null @@ -1,275 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml deleted file mode 100644 index 79ee123..0000000 --- a/.idea/codeStyles/codeStyleConfig.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 8d66637..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/jsonSchemas.xml b/.idea/jsonSchemas.xml deleted file mode 100644 index f1eb34e..0000000 --- a/.idea/jsonSchemas.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/.idea/ktlint-plugin.xml b/.idea/ktlint-plugin.xml deleted file mode 100644 index bee5678..0000000 --- a/.idea/ktlint-plugin.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - DISTRACT_FREE - - \ No newline at end of file diff --git a/.idea/material_theme_project_new.xml b/.idea/material_theme_project_new.xml deleted file mode 100644 index 72c8d75..0000000 --- a/.idea/material_theme_project_new.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 1d7c5cf..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - Kotlin - - - Redundant constructsKotlin - - - - - RedundantSemicolon - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 8f1a808..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/prettier.xml b/.idea/prettier.xml deleted file mode 100644 index edd645a..0000000 --- a/.idea/prettier.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/skn-rust-utils.iml b/.idea/skn-rust-utils.iml deleted file mode 100644 index 9b4cf84..0000000 --- a/.idea/skn-rust-utils.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.prettierignore b/.prettierignore index e5eceec..9480ead 100644 --- a/.prettierignore +++ b/.prettierignore @@ -111,6 +111,10 @@ wwwroot *.nupkg packages -# VS Code/JetBrains IDE -!icon.tar.gz -!*-settings.zip +# JetBrains IDE +.idea +!.idea/icon.tar.gz +!.idea/*-settings.zip +*.iws +*.iml +*.ipr diff --git a/Cargo.toml b/Cargo.toml index eeaa715..4b0a327 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "best_skn_utils" description = "A Simple Utility Library For Rust" -version = "1.1.0" +version = "1.2.0" edition = "2021" rust-version = "1.78.0" readme = "README.md" @@ -20,7 +20,7 @@ best_skn_message = "1.2.1" config = { version = "0.14.0", features = ["toml", "yaml"] } serde = { version = "1.0.203", features = ["derive"] } num = "0.4.3" -rand = "0.9.0-alpha.1" +rand = "0.8.5" [profile.dev] opt-level = 0 diff --git a/README.md b/README.md index f3dcb3a..73bec75 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,11 @@ ### Read the Rustdoc for the main Modules -- [env](https://docs.rs/best_skn_utils/1.1.0/best_skn_utils/env/index.html) -- [execution](https://docs.rs/best_skn_utils/1.1.0/best_skn_utils/execution/index.html) -- [stdio](https://docs.rs/best_skn_utils/1.1.0/best_skn_utils/stdio/index.html) -- [random](https://docs.rs/best_skn_utils/1.1.0/best_skn_utils/random/index.html) +- [env](https://docs.rs/best_skn_utils/1.2.0/best_skn_utils/env/index.html) +- [execution](https://docs.rs/best_skn_utils/1.2.0/best_skn_utils/execution/index.html) +- [stdio](https://docs.rs/best_skn_utils/1.2.0/best_skn_utils/stdio/index.html) +- [random](https://docs.rs/best_skn_utils/1.2.0/best_skn_utils/random/index.html) +- [args](https://docs.rs/best_skn_utils/1.2.0/best_skn_utils/args/index.html)   @@ -25,7 +26,7 @@ ### I made this library so that I can use it in all of my rust projects without writing the same codes over and over again -### The main Modules of this library are `env`, `execution` & `stdio` +### The main Modules of this library are `env`, `execution`, `stdio`, `random` & `args`   @@ -66,6 +67,12 @@ - The second parameter `high` is inclusive i.e. a range of 1 and 10 will mean the range includes from 1 to 10 - See `Usage` section to get an example of how to use it +### **`args` Module** + +- It has 1 function that provides a collection of arguments passed in command line interface +- `get_args` function returns a collection as a vector of String +- See `Usage` section to get an example of how to use it +   ## **_Use Case:_** @@ -79,6 +86,9 @@ - 💀 Minimum Rust Version: `1.78.0` - 💀 Crates: - [serde](https://crates.io/crates/serde): `1.0.203` + - [num](https://crates.io/crates/num): `0.4.3` + - [rand](https://crates.io/crates/rand): `0.8.5` + - [config](https://crates.io/crates/config): `0.14.0`   @@ -93,7 +103,7 @@ ### Inside your Rust Code, import the package like this > ```rust -> use best_skn_utils::{env, execution, stdio, random}; +> use best_skn_utils::{env, execution, stdio, random, args}; > ``` ### Use the modules like the following (Just an example) @@ -188,6 +198,16 @@ > let num2: f64 = gen_random_number(1.5, 7.5); > ``` +#### (5) For `args` module, you can use like this + +> ```rust +> use best_skn_utils::args::get_args; +> +> let args: Vec = get_args(); +> +> println!("{:?}", args); +> ``` +   ## **_Dedicated To:_** diff --git a/src/args.rs b/src/args.rs new file mode 100644 index 0000000..3b9f4bb --- /dev/null +++ b/src/args.rs @@ -0,0 +1,25 @@ +use std::env; + +/// Provides the arguments passed in command line interface +/// +/// ## Returns: +/// +/// `Vec`: A vector of String +/// +/// ## Since: +/// +/// v1.2.0 +/// +/// ## Example: +/// +/// ```rust +/// use best_skn_utils::args::get_args; +/// +/// let args: Vec = get_args(); +/// +/// println!("{:?}", args); +/// ``` +pub fn get_args() -> Vec { + let args: Vec = env::args().collect(); + return args; +} diff --git a/src/lib.rs b/src/lib.rs index 459a220..877c0fa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,16 +10,21 @@ //! external config //! - This crate's `execution` module has 2 functions to help execute commands in terminal //! - This crate's `stdio` module has 1 function to read input value in the terminal +//! - This crate's `random` module has 1 function that generates a random number in a given range +//! - This crate's `args` module has 1 function that returns a collection of arguments passed in command line interface //! //! ## Minimum Requirements: //! //! - 💀 Rust Version: **1.78.0** //! - 💀 Crates: //! - serde: **1.0.203** +//! - num: **0.4.3** +//! - rand: **0.8.5** +//! - config: **0.14.0** //! //! ## Version: //! -//! 1.1.0 +//! 1.2.0 /// This module provides functionality for building an external configuration /// @@ -66,3 +71,14 @@ pub mod stdio; /// /// 2024-06-19 pub mod random; + +/// This module provides functionality for getting arguments passed in command line interface +/// +/// ## `args` module +/// +/// - It has 1 function that returns a collection of arguments in command line interface +/// +/// ## Since: +/// +/// 2024-07-12 +pub mod args;