You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+78-43Lines changed: 78 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,15 +10,13 @@ _A Rust library for console-based user input, option selection, control, and mor
10
10
11
11
This crate offers utility functions for various console-related operations in Rust programs. From obtaining user input to achieving precise terminal control, its main focus is to remain simple while providing extensive functionality.
12
12
13
-
14
-
15
13
## Usage
16
14
17
15
To use Console Utils in your Rust project, you can add the following dependency to your `Cargo.toml` file:
18
16
19
17
```toml
20
18
[dependencies]
21
-
console-utils = "1.5.9"
19
+
console-utils = "1.6.0"
22
20
```
23
21
24
22
After adding the dependency, you can import the modules you need in your Rust code. For example:
@@ -28,48 +26,85 @@ use console_utils::input::{input, select};
28
26
useconsole_utils::control::{flush, clear_line};
29
27
```
30
28
31
-
## Example
29
+
## Examples
30
+
31
+
### Reading User Input
32
+
33
+
```rust, no_run
34
+
use console_utils::input::input;
35
+
// Read user input as a string
36
+
let user_input: String = input("Enter something: ");
37
+
38
+
println!("You entered: {}", user_input);
39
+
```
40
+
41
+
### Selecting Options
42
+
43
+
#### Single Option
44
+
```rust, no_run
45
+
use console_utils::input::select;
46
+
let options = [
47
+
"Option 1",
48
+
"Option 2",
49
+
"Option 3",
50
+
];
51
+
// Allow the user to select one option
52
+
let selected_index = select("Select an option:", &options);
0 commit comments