-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli/search): implement search command
- Loading branch information
Showing
3 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
pub mod env; | ||
pub mod config; | ||
pub mod show; | ||
pub mod search; | ||
pub mod install; | ||
pub mod add; | ||
pub mod remove; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use saku_lib::pkg::data; | ||
use saku_lib::prelude::*; | ||
use saku_lib::util::path; | ||
|
||
pub fn search(pattern: &str) -> Result<()> { | ||
let pkgs: Vec<[String;2]> = path::pkg_match(&pattern)?; | ||
if pkgs.len() == 0 { | ||
return Err(make_err!(NotFound, "no packages matching that name were found")) | ||
} | ||
|
||
pkgs.iter().map( | ||
|p| { | ||
let (group, name) = (p[0].clone(), p[1].clone()); | ||
debug!("found pkg {}/{}", &group, &name); | ||
let path = path::path_pkg(&group, &name); | ||
let pkg = data::get_pkg_from_path(&path)?; | ||
pkg.show()?; | ||
Ok(()) | ||
}).collect::<Result<()>>()?; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters