fn list_commands() -> BTreeSet<String> {
    let prefix = "stick-";
    let suffix = env::consts::EXE_SUFFIX;
    let mut commands = BTreeSet::new();
    for dir in search_directories() {
        let entries = match fs::read_dir(dir) {
            Ok(entries) => entries,
            _ => continue,
        };
        for entry in entries.filter_map(|e| e.ok()) {
            let path = entry.path();
            let filename = match path.file_name().and_then(|s| s.to_str()) {
                Some(filename) => filename,
                _ => continue,
            };
            if !filename.starts_with(prefix) || !filename.ends_with(suffix) {
                continue;
            }
            if is_executable(entry.path()) {
                let end = filename.len() - suffix.len();
                commands.insert(filename[prefix.len()..end].to_string());
            }
        }
    }

    macro_rules! add_cmd {
        ($cmd:ident) => ({ commands.insert(stringify!($cmd).replace("_", "-")); })
    }
    each_subcommand!(add_cmd);

    commands
}
/// List all runnable commands. find_command should always succeed
/// if given one of returned command.
List all runnable commands. find_command should always succeed
if given one of returned command.
List all runnable commands . find_command should always succeed if given one of returned command .
fn list_commands() -> BTreeSet<String> {
    let prefix = "stick-";
    let suffix = env::consts::EXE_SUFFIX;
    let mut commands = BTreeSet::new();
    for dir in search_directories() {
        let entries = match fs::read_dir(dir) {
            Ok(entries) => entries,
            _ => continue,
        };
        for entry in entries.filter_map(|e| e.ok()) {
            let path = entry.path();
            let filename = match path.file_name().and_then(|s| s.to_str()) {
                Some(filename) => filename,
                _ => continue,
            };
            if !filename.starts_with(prefix) || !filename.ends_with(suffix) {
                continue;
            }
            if is_executable(entry.path()) {
                let end = filename.len() - suffix.len();
                commands.insert(filename[prefix.len()..end].to_string());
            }
        }
    }
    macro_rules! add_cmd {
        ($cmd:ident) => ({ commands.insert(stringify!($cmd).replace("_", "-")); })
    }
    each_subcommand!(add_cmd);
    commands
}
fn list_commands ( ) -> BTreeSet < String > { let prefix = " " ; let suffix = env :: consts :: EXE_SUFFIX ; let mut commands = BTreeSet :: new ( ) ; for dir in search_directories ( ) { let entries = match fs :: read_dir ( dir ) { Ok ( entries ) => entries , _ => continue , } ; for entry in entries . filter_map ( | e | e . ok ( ) ) { let path = entry . path ( ) ; let filename = match path . file_name ( ) . and_then ( | s | s . to_str ( ) ) { Some ( filename ) => filename , _ => continue , } ; if ! filename . starts_with ( prefix ) || ! filename . ends_with ( suffix ) { continue ; } if is_executable ( entry . path ( ) ) { let end = filename . len ( ) - suffix . len ( ) ; commands . insert ( filename [ prefix . len ( ) .. end ] . to_string ( ) ) ; } } } macro_rules! add_cmd { ( $cmd : ident ) => ( { commands insert ( stringify ( $cmd ) replace ( " " " " ) ) } ) } each_subcommand ! ( add_cmd ) ; commands }
List all runnable commands.
List all runnable commands .