@@ -8,17 +8,39 @@ use split_non_quoted::split_non_quoted;
88use crate :: prelude:: * ;
99
1010impl 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