Skip to content

Commit 27608fd

Browse files
committed
chore: add a bit of docs
Signed-off-by: jschwabe <mail@jschwabe.site>
1 parent 3c88991 commit 27608fd

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

src/tokenizer/mod.rs

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,39 @@ use split_non_quoted::split_non_quoted;
88
use crate::prelude::*;
99

1010
impl t_shell {
11+
/// Sets up pipes and their commands/arguments, including redirections
1112
///
12-
/// sets up pipes and their commands/arguments, including redirections
13+
/// # Examples
1314
///
14-
// /// # Example
15-
// /// ```
16-
/// let mut trimmed_line = "echo hello | cat > somefile";
15+
/// Basic pipe operation:
16+
/// ```no_run
17+
/// # use minishell_rs::t_shell;
1718
/// let mut shell = t_shell::new();
18-
/// assert!(shell.tokenize(trimmed_line).is_some());
19-
// /// ```
19+
/// assert!(shell.tokenize("echo hello | cat").is_some());
20+
/// ```
2021
///
21-
pub(super) fn tokenize(&mut self, trimmed_line: &str) -> Option<()> {
22+
/// Pipe with redirection:
23+
/// ```no_run
24+
/// # use minishell_rs::t_shell;
25+
/// let mut shell = t_shell::new();
26+
/// assert!(shell.tokenize("echo hello | cat > outfile").is_some());
27+
/// ```
28+
///
29+
/// Multiple pipes:
30+
/// ```no_run
31+
/// # use minishell_rs::t_shell;
32+
/// let mut shell = t_shell::new();
33+
/// assert!(shell.tokenize("ls -l | grep test | wc -l").is_some());
34+
/// ```
35+
///
36+
/// Empty input handling:
37+
/// ```no_run
38+
/// # use minishell_rs::t_shell;
39+
/// let mut shell = t_shell::new();
40+
/// assert!(shell.tokenize("").is_none());
41+
/// assert!(shell.tokenize("|").is_none());
42+
/// ```
43+
pub fn tokenize(&mut self, trimmed_line: &str) -> Option<()> {
2244
let mut split_pipes = split_non_quoted(trimmed_line, "|");
2345
assert!(!split_pipes.is_empty());
2446
if split_pipes.first().unwrap().is_empty() {

0 commit comments

Comments
 (0)