MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / prefix

Method prefix

crates/opencode-permission/src/arity.rs:6–19  ·  view source on GitHub ↗
(tokens: &[String])

Source from the content-addressed store, hash-verified

4
5impl BashArity {
6 pub fn prefix(tokens: &[String]) -> Vec<String> {
7 for len in (1..=tokens.len()).rev() {
8 let prefix: String = tokens[..len].join(" ");
9 if let Some(&arity) = ARITY.get(prefix.as_str()) {
10 return tokens[..arity].to_vec();
11 }
12 }
13
14 if tokens.is_empty() {
15 return vec![];
16 }
17
18 tokens[..1].to_vec()
19 }
20}
21
22lazy_static::lazy_static! {

Callers

nothing calls this directly

Calls 3

is_emptyMethod · 0.80
getMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected