Skip to content
This repository has been archived by the owner on Jan 8, 2022. It is now read-only.

Cli ergonomics #9

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ time = "^0.1"
structopt = "0.2.8"
failure = "0.1.1"
human-panic = "1.0.0"
log = "0.4.0"
env_logger = "0.5.10"
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extern crate time;
extern crate structopt;
#[macro_use]
extern crate failure;
extern crate log;

use cargo::core::registry::PackageRegistry;
use cargo::core::resolver::Method;
Expand Down
19 changes: 18 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
extern crate human_panic;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if someone inputted the wrong arguments we're not going to show them the following:

Well, this is embarrassing.

cargo-ebuild had a problem and crashed. To help us diagnose the problem you can send us a crash report.

We have generated a report file at "/var/folders/zw/bpfvmq390lv2c6gn_6byyv0w0000gn/T/report-8351cad6-d2b5-4fe8-accd-1fcbf4538792.toml". Submit an issue or email with the subject of "human-panic Crash Report" and include the report as an attachment.

- Homepage: https://github.com/cardoe/cargo-ebuild
- Authors: Doug Goldstein <[email protected]>

We take privacy seriously, and do not perform any automated error collection. In order to improve the software, we rely on people to submit reports.

Thank you kindly!

This is the wrong crate for the job. Printing out a reasonable error message worked previously and this isn't reasonable.

#[macro_use]
extern crate structopt;
extern crate env_logger;
extern crate cargo_ebuild;
extern crate log;

use log::Level as LogLevel;
use cargo_ebuild::*;
use structopt::StructOpt;

Expand All @@ -32,9 +35,23 @@ pub struct Cli {
}

fn main() -> Result<(), Error> {
setup_panic!();

let args = Cli::from_args();

setup_panic!();
env_logger::Builder::new()
.filter(
None,
match args.verbosity {
0 => LogLevel::Error,
1 => LogLevel::Warn,
2 => LogLevel::Info,
3 => LogLevel::Debug,
_ => LogLevel::Trace,
}.to_level_filter(),
)
.try_init()?;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have nothing using log macros. What value is this providing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all the warns in cargo_ebuild::build are log. Log will be used more in future.



run_cargo_ebuild(args.cmd)
}