added quietness flag, set default log level to info
This commit is contained in:
parent
9fb647f214
commit
4acbcaaa9b
3 changed files with 47 additions and 20 deletions
|
@ -2,7 +2,7 @@
|
|||
Dates are given in YYYY-MM-DD format.
|
||||
|
||||
## v0.3
|
||||
### v0.3.0 (2021-xx-yy)
|
||||
### v0.3.0 (2021-04-28)
|
||||
#### Features
|
||||
- Added `-x`/`--exclude` flag for excluding file extensions (overrides `-e` or `-E` - `-E images -x jpg` scans all image
|
||||
files, except ".jpg" files)
|
||||
|
@ -13,13 +13,18 @@ Dates are given in YYYY-MM-DD format.
|
|||
will scan all images *and* all MP3 files
|
||||
- It is now possible to specify multiple extension sets at once: `-E images,system` will scan all images and archives
|
||||
- fif's output now includes the directory it was run from
|
||||
- Added `-q`/`--quiet` flag for reducing output verbosity
|
||||
#### Bugfixes
|
||||
- Resolved some discrepancies between `application/xml` and `text/xml`
|
||||
#### Other
|
||||
- Published my fork of ['mime_guess'] as ['new_mime_guess'], allowing it to be used properly with
|
||||
[crates.io](https://crates.io)
|
||||
- The `videos` extension set has been renamed to `video`, in line with `audio`. `fif --help` has actually mistakenly
|
||||
referred to the set as `video` since v0.2.12! 0uo
|
||||
- CI has been vastly improved
|
||||
- Changed default verbosity to `info`
|
||||
|
||||
## v0.2
|
||||
### v0.2.13 (2021-04-26)
|
||||
#### Features
|
||||
- Added `-v`/`--verbose` flag for setting verbosity without using `RUST_LOG`
|
||||
|
|
26
README.md
26
README.md
|
@ -100,23 +100,35 @@ fif -O powershell ~/Documents > output.ps1
|
|||
```
|
||||
|
||||
### Logging
|
||||
By default, fif will log any warnings and/or errors encountered during execution. This can be changed with the `-v`
|
||||
By default, fif will log any info, warnings, and errors encountered during execution. This can be changed with the `-v`
|
||||
flag:
|
||||
```bash
|
||||
# also log info
|
||||
# also log debug info
|
||||
fif -v ~/Downloads
|
||||
# ...and debug
|
||||
# ...and trace info
|
||||
fif -vv ~/Downloads
|
||||
# ...and trace
|
||||
fif -vvv ~/Downloads
|
||||
```
|
||||
The verbosity of the logging can be
|
||||
modified by the `RUST_LOG` to one of: `trace`, `debug`, `info`, `warn`, `error`.
|
||||
|
||||
You can also reduce the level of logging with the `-q` flag:
|
||||
```bash
|
||||
# don't show info
|
||||
fif -q ~/Downloads
|
||||
# ...or warnings
|
||||
fif -qq ~/Downloads
|
||||
# ...or even errors!
|
||||
fif -qqq ~/Downloads
|
||||
```
|
||||
|
||||
The verbosity of the logging can also be modified by setting the environment variable `RUST_LOG` to `off`, `trace`,
|
||||
`debug`, `info`, `warn`, or `error`. Values set by `RUST_LOG` override the `-v` and `-q` flags.
|
||||
|
||||
For example:
|
||||
|
||||
```bash
|
||||
# show all levels except trace
|
||||
RUST_LOG=debug fif ~/Downloads
|
||||
# only show errors
|
||||
RUST_LOG=error fif ~/Downloads
|
||||
```
|
||||
|
||||
The five logging levels are used as follows:
|
||||
|
|
|
@ -48,23 +48,23 @@ pub struct Parameters {
|
|||
/// Only examine files with these extensions.
|
||||
/// Multiple extensions can be specified by either using the flag multiple times (`-e jpg -e png -e gif`), or by
|
||||
/// separating them with commas (`-e jpg,png,gif`).
|
||||
#[clap(short, long, use_delimiter = true, require_delimiter = true)]
|
||||
#[clap(short, long, use_delimiter = true, require_delimiter = true, value_name = "ext")]
|
||||
pub exts: Option<Vec<StringType>>,
|
||||
|
||||
/// Use these preset lists of extensions as the search filter (comma-separated list).
|
||||
/// `media` includes all extensions from the `audio`, `video`, and `images` sets, making `-E media` equivalent to
|
||||
/// `-E audio,video,images`.
|
||||
#[clap(short = 'E', long, arg_enum, use_delimiter = true, require_delimiter = true)]
|
||||
#[clap(short = 'E', long, arg_enum, use_delimiter = true, require_delimiter = true, value_name = "set")]
|
||||
pub ext_set: Vec<ExtensionSet>,
|
||||
|
||||
/// Don't scan files with these extensions.
|
||||
/// This option takes precedence over extensions specified with `-e` or `-E`.
|
||||
#[clap(short = 'x', long, use_delimiter = true, require_delimiter = true)]
|
||||
#[clap(short = 'x', long, use_delimiter = true, require_delimiter = true, value_name = "ext")]
|
||||
pub exclude: Option<Vec<StringType>>,
|
||||
|
||||
/// Exclude files using a preset list of extensions.
|
||||
/// This option takes precedence over extensions specified with `-e` or `-E`.
|
||||
#[clap(short = 'X', long, arg_enum, use_delimiter = true, require_delimiter = true)]
|
||||
#[clap(short = 'X', long, arg_enum, use_delimiter = true, require_delimiter = true, value_name = "set")]
|
||||
pub exclude_set: Vec<ExtensionSet>,
|
||||
|
||||
/// Don't skip hidden files and directories.
|
||||
|
@ -81,18 +81,22 @@ pub struct Parameters {
|
|||
|
||||
/// Output format to use.
|
||||
/// By default, fif will output a PowerShell script on Windows, and a Bourne Shell script on other platforms.
|
||||
#[clap(short, long, default_value = DEFAULT_FORMAT, arg_enum)]
|
||||
#[clap(short, long, default_value = DEFAULT_FORMAT, arg_enum, value_name = "format")]
|
||||
pub output_format: OutputFormat,
|
||||
|
||||
/// Follow symlinks.
|
||||
#[clap(short, long)]
|
||||
pub follow_symlinks: bool,
|
||||
|
||||
/// Output verbosity. Defaults to only logging warnings and errors.
|
||||
/// Output verbosity. Each additional `-v` increases verbosity.
|
||||
/// Can be overridden by RUST_LOG.
|
||||
#[clap(short, long, parse(from_occurrences))]
|
||||
#[clap(short, long, parse(from_occurrences), group = "verbosity")]
|
||||
pub verbose: u8,
|
||||
|
||||
/// Output quietness. Each additional `-q` decreases verbosity.
|
||||
#[clap(short, long, parse(from_occurrences), group = "verbosity")]
|
||||
pub quiet: u8,
|
||||
|
||||
/// The directory to process.
|
||||
// TODO: right now this can only take a single directory - should this be improved?
|
||||
#[clap(name = "DIR", default_value = ".", parse(from_os_str))]
|
||||
|
@ -182,11 +186,17 @@ impl Parameters {
|
|||
#![allow(clippy::missing_const_for_fn)]
|
||||
// match was not permitted inside const functions until 1.46
|
||||
|
||||
match self.quiet {
|
||||
0 => {
|
||||
match self.verbose {
|
||||
0 => "warn",
|
||||
1 => "info",
|
||||
2 => "debug",
|
||||
_ => "trace",
|
||||
0 => "info", // no verbosity flags specified
|
||||
1 => "debug", // -v
|
||||
_ => "trace" // -vv...
|
||||
}
|
||||
},
|
||||
1 => "warn", // -q
|
||||
2 => "error", // -qq
|
||||
_ => "off" // -qqq...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue