diff options
-rw-r--r-- | src/backend.rs | 3 | ||||
-rw-r--r-- | src/main.rs | 33 |
2 files changed, 31 insertions, 5 deletions
diff --git a/src/backend.rs b/src/backend.rs index fe1fa7e..c29b05e 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -43,9 +43,10 @@ impl Api for Backend { pub fn new_backend(app: &ArgMatches, config: &Configuration) -> Result<Backend> { if app.is_present("input_stdin") { + trace!("Building new STDIN backend"); Ok(Backend::Stdin(StdinWrapper::from(::std::io::stdin()))) } else { - debug!("Constructing backend"); + trace!("Building new remote backend"); let url = config.repology_url().as_str().into(); trace!("url = {}", url); Ok(Backend::RepologyOrg(RestApi::new(url))) diff --git a/src/main.rs b/src/main.rs index 6c3442e..2f1b9a6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -112,8 +112,10 @@ fn app() -> Result<()> { .value_of("config") .map(PathBuf::from) { + debug!("Found passed configuration file at {}", path.display()); Ok(path) } else { + debug!("Searching for configuration in XDG"); xdg::BaseDirectories::new()? .find_config_file("repolocli.toml") .ok_or_else(|| err_msg("Cannot find repolocli.toml")) @@ -129,8 +131,13 @@ fn app() -> Result<()> { }?; trace!("Config deserialized"); + debug!("Initializing Backend"); let backend = crate::backend::new_backend(&app, &config)?; + debug!("Backend initialized"); + + debug!("Initializing Frontend"); let frontend = crate::frontend::new_frontend(&app, &config)?; + debug!("Frontend initialized"); let repository_filter = { let blacklist_filter = |repo: &Repo| -> bool { @@ -155,10 +162,11 @@ fn app() -> Result<()> { blacklist_filter.or(whitelist_filter) }; + debug!("Repository filter constructed successfully"); match app.subcommand() { ("project", Some(mtch)) => { - trace!("Handling project"); + debug!("Subcommand: 'project'"); trace!("sort-versions: {}", mtch.is_present("sort-version")); trace!("sort-repository: {}", mtch.is_present("sort-repo")); @@ -173,20 +181,22 @@ fn app() -> Result<()> { }; let mut packages: Vec<Package> = { + debug!("Fetching packages"); let iter = backend .project(&name)? .into_iter() .filter(|package| repository_filter.filter(package.repo())); if mtch.is_present("sort-version"){ - debug!("Sorting by version"); + trace!("Sorting by version"); iter.sorted_by(|a, b| Ord::cmp(a.version(), b.version())) .collect() } else if mtch.is_present("sort-repo") { - debug!("Sorting by repository"); + trace!("Sorting by repository"); iter.sorted_by(|a, b| Ord::cmp(a.repo(), b.repo())) .collect() } else { + trace!("Not sorting"); iter.collect() } }; @@ -213,15 +223,21 @@ fn app() -> Result<()> { packages }; + debug!("Listing packages in frontend"); frontend.list_packages(packages) }, + ("problems", Some(mtch)) => { - trace!("Handling problems"); + debug!("Subcommand: 'problems'"); let repo = mtch.value_of("repo"); let maintainer = mtch.value_of("maintainer"); + trace!("repo = {:?}", repo); + trace!("maintainer = {:?}", maintainer); + let problems = { + debug!("Finding problems..."); let iter = match (repo, maintainer) { (Some(r), None) => backend.problems_for_repo(&r)?, (None, Some(m)) => backend.problems_for_maintainer(&m)?, @@ -232,28 +248,36 @@ fn app() -> Result<()> { .filter(|problem| repository_filter.filter(problem.repo())); if mtch.is_present("sort-maintainer") { + trace!("Sorting problems by maintainer"); iter.sorted_by(|a, b| Ord::cmp(a.maintainer(), b.maintainer())) .collect() } else if mtch.is_present("sort-repo") { + trace!("Sorting problems by repo"); iter.sorted_by(|a, b| Ord::cmp(a.repo(), b.repo())) .collect() } else { + trace!("Not sorting problems"); iter.collect() } }; + debug!("Listing problems in frontend"); frontend.list_problems(problems) }, + ("compare", Some(mtch)) => { + debug!("Subcommand: 'compare'"); let repos = mtch.values_of("compare-distros").unwrap().map(String::from).map(Repo::new).collect(); let file_path = mtch.value_of("compare-list").unwrap(); // safe by clap let content = ::std::fs::read_to_string(file_path)?; let pkgs : Vec<ComparePackage> = deserialize_package_list(content, file_path)?; + debug!("Comparing packages..."); frontend.compare_packages(pkgs, &backend, repos) }, (other, _mtch) => { + debug!("Subcommand: {}", other); app.is_present("input_stdin") .as_result((), Error::from(format_err!("Input not from stdin"))) .and_then(|_| { @@ -267,6 +291,7 @@ fn app() -> Result<()> { .filter(|package| repository_filter.filter(package.repo())) .collect(); + debug!("Listing packages"); frontend.list_packages(packages) }) .map_err(|_| format_err!("Unknown command: {}", other)) |