MCPcopy Create free account
hub / github.com/corrode/write-yourself-a-shell / parse_cmd

Method parse_cmd

examples/final.rs:92–112  ·  view source on GitHub ↗
(
        binary: &'a str,
        tokens: &mut Peekable<I>,
    )

Source from the content-addressed store, hash-verified

90 }
91
92 fn parse_cmd<I: Iterator<Item = &'a str>>(
93 binary: &'a str,
94 tokens: &mut Peekable<I>,
95 ) -> Option<Cmd<'a>> {
96 let mut args: Vec<&str> = vec![];
97 loop {
98 let next = tokens.peek();
99 match next {
100 Some(token) if Self::is_operator(token) => {
101 // found operator, so I already parsed all cmd
102 break;
103 }
104 Some(token) => {
105 args.push(token);
106 }
107 None => break,
108 }
109 tokens.next();
110 }
111 Some(Cmd { binary, args })
112 }
113}
114
115impl<'a> Cmd<'a> {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected