diff --git a/Cargo.lock b/Cargo.lock index f1524b2..41b1885 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -226,7 +226,7 @@ dependencies = [ [[package]] name = "quicli" -version = "0.1.1" +version = "0.1.2" dependencies = [ "env_logger 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index e59e2ff..725d579 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "quicli" -version = "0.1.1" +version = "0.1.2" description = "Quickly build cool CLI apps in Rust." authors = ["Pascal Hertleif "] readme = "Readme.md" diff --git a/Changelog.md b/Changelog.md new file mode 100644 index 0000000..9451bd1 --- /dev/null +++ b/Changelog.md @@ -0,0 +1,50 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [0.1.2] - 2018-01-28 + +### Added + +- [A website with guides!](https://killercup.github.io/quicli/) +- `glob` +- `create_dir` +- Re-export Rayon traits +- Export `Result` type alias using failure's Error + +## Removed + +- All the examples are now guides + +## Changed + +- `main!` now sets up logging in all cases +- Use buffered reading/writing in fs functions + +## [0.1.1] - 2018-01-28 + +### Added + +- Re-export log macros +- Automatically set up env_logger in main! +- `main!` parameter for Cli struct and its logging level field +- Readme fixes +- Expose fs module + +## [0.1.0] - 2018-01-28 + +### Added + +- `main!` macro +- Re-exports of failure, serde, structopt +- Commit Message generator example +- read/write file functions + +[Unreleased]: https://github.com/killercup/quicli/compare/v1.0.0...HEAD +[0.1.2]: https://github.com/killercup/quicli/compare/v0.1.0...v0.1.2 +[0.1.1]: https://github.com/killercup/quicli/compare/v0.1.0...v0.1.1 +[0.1.0]: https://github.com/killercup/quicli/compare/cb747195866d2a240ab8154d00facfead3e55a9e...v0.1.0 diff --git a/src/fs.rs b/src/fs.rs index 1eae227..6d243c2 100644 --- a/src/fs.rs +++ b/src/fs.rs @@ -83,7 +83,7 @@ pub fn write_to_file>(path: P, content: &str) -> Result<()> { /// # fn main() { run().unwrap() } /// # fn run() -> Result<()> { /// let markdown_files = glob("*.md")?; -/// assert_eq!(markdown_files.len(), 1); +/// assert_eq!(markdown_files.len(), 2); /// /// let weird_files = glob("**/*.weird"); /// assert!(weird_files.is_err()); diff --git a/src/main_macro.rs b/src/main_macro.rs index 222354a..416bf98 100644 --- a/src/main_macro.rs +++ b/src/main_macro.rs @@ -1,7 +1,8 @@ /// Quickly get a good `main` function /// /// Inside the block, you can write code using `?`. An `Ok(())` will -/// automatically be appended. +/// automatically be appended. The macro will also set up logging (using +/// `env_logger`) automatically. /// /// # Parameters /// @@ -11,14 +12,10 @@ /// - `main!(|args: Cli| { ... })`: Automatically parses command line flags into /// a struct `Cli` and binds it to `args`. (Basically, it prepends /// `let args = Cli::from_args();`). -/// - `main!(|args: Cli, log_level: verbosity| { ... })`: In addition to parsing -/// the command line flags into `args` of type `Cli`, it will also initialize -/// a logger. -/// -/// The log level will depend on the integer value of the `verbosity` field of -/// `args` (error = 0, warn = 1, info = 2, debug = 3, trace = ≥4). The field's -/// type should be `u64`, so structopt will automatically give you its -/// number of occurances. +/// - `main!(|args: Cli, log_level: verbosity| { ... })`: The log level will +/// depend on the integer value of the `verbosity` field of `args` (error = 0, +/// warn = 1, info = 2, debug = 3, trace = ≥4). The field's type should be +/// `u64`, so structopt will automatically give you its number of occurances. /// /// # Examples /// @@ -94,6 +91,11 @@ macro_rules! main { ($body:expr) => { fn main() { fn run() -> $crate::prelude::Result<()> { + $crate::prelude::LoggerBuiler::new() + .filter(Some(env!("CARGO_PKG_NAME")), $crate::prelude::LogLevel::Error.to_level_filter()) + .filter(None, $crate::prelude::LogLevel::Warn.to_level_filter()) + .try_init()?; + $body Ok(()) }