pub fn classify_command(tokens: &[&str]) -> StringExpand description
Return the canonical command prefix for a slice of command tokens.
The prefix is determined by the COMMAND_ARITY dictionary:
- Tokens that start with
-are treated as flags and skipped — they never contribute to arity. - The arity value
nmeans thatnpositional words (including the base command name) form the canonical prefix. - The longest matching dictionary entry wins (greedy).
- If no dictionary entry matches, the single base command word is returned as the prefix.
§Examples
["git", "status", "-s"] -> "git status"
["git", "push", "origin"] -> "git push"
["cargo", "check", "--workspace"] -> "cargo check"
["npm", "run", "dev"] -> "npm run dev"
["ls", "-la"] -> "ls"