asimov_cli/shared.rs
1// This is free and unencumbered software released into the public domain.
2
3use crate::{Result, Subcommand, SubcommandsProvider};
4use clientele::SysexitsError::*;
5
6/// Locates the given subcommand or prints an error.
7pub fn locate_subcommand(name: &str) -> Result<Subcommand> {
8 match SubcommandsProvider::find("asimov-", name) {
9 Some(cmd) => Ok(cmd),
10 None => {
11 eprintln!("{}: command not found: {}{}", "asimov", "asimov-", name);
12 Err(EX_UNAVAILABLE)
13 }
14 }
15}