-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
auto merge of #959 : jakub-/cargo/cargo-search, r=alexcrichton
This will currently call out to the registry service. In the future it may be sensible to add package descriptions to the git index so that search can be done offline. Closes #925.
- Loading branch information
Showing
5 changed files
with
124 additions
and
19 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
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,35 @@ | ||
use cargo::ops; | ||
use cargo::core::{MultiShell}; | ||
use cargo::util::{CliResult, CliError}; | ||
|
||
#[deriving(Decodable)] | ||
struct Options { | ||
flag_host: Option<String>, | ||
flag_verbose: bool, | ||
arg_query: String | ||
} | ||
|
||
pub const USAGE: &'static str = " | ||
Search packages in crates.io | ||
Usage: | ||
cargo search [options] <query> | ||
Options: | ||
-h, --help Print this message | ||
--host HOST Host of a registry to search in | ||
-v, --verbose Use verbose output | ||
"; | ||
|
||
pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> { | ||
shell.set_verbose(options.flag_verbose); | ||
let Options { | ||
flag_host: host, | ||
arg_query: query, | ||
.. | ||
} = options; | ||
|
||
ops::search(query.as_slice(), shell, host) | ||
.map(|_| None) | ||
.map_err(|err| CliError::from_boxed(err, 101)) | ||
} |
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
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
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