nicer output for --help
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Lynne Megido 2021-03-01 20:20:46 +10:00
parent 5907309689
commit 4412161193
3 changed files with 19 additions and 4 deletions

View file

@ -14,6 +14,9 @@ exclude = [".idea/", "Cross.toml", "*.sh", "*.py", ".drone.yml"]
#resolver = "2" #resolver = "2"
#license-file = "LICENSE" #license-file = "LICENSE"
[badges]
maintenance = { status = "experimental" }
[features] [features]
default = ["multi-threaded"] default = ["multi-threaded"]
multi-threaded = ["rayon"] multi-threaded = ["rayon"]

View file

@ -3,19 +3,31 @@
use std::path::PathBuf; use std::path::PathBuf;
use crate::extension_set::ExtensionSet; use crate::extension_set::ExtensionSet;
use clap::{Clap}; use clap::{Clap, AppSettings};
use smartstring::{LazyCompact, SmartString}; use smartstring::{LazyCompact, SmartString};
#[derive(Clap, PartialEq, Debug)] #[derive(Clap, PartialEq, Debug)]
pub enum OutputFormat { pub enum OutputFormat {
/// A Bourne shell compatible script.
Script, Script,
/// Plain text.
Text, Text,
} }
// TODO: convert this to macro style?: https://docs.rs/clap/3.0.0-beta.2/clap/index.html#using-macros // TODO: convert this to macro style?: https://docs.rs/clap/3.0.0-beta.2/clap/index.html#using-macros
#[derive(Clap, Debug)] #[derive(Clap, Debug)]
#[clap(version = option_env!("CARGO_PKG_VERSION").unwrap_or("???"))] #[clap(
version = option_env!("CARGO_PKG_VERSION").unwrap_or("???"),
author = option_env!("CARGO_PKG_AUTHORS").unwrap_or("Lynnesbian"),
about = option_env!("CARGO_PKG_DESCRIPTION").unwrap_or("File Info Fixer"),
before_help = "Copyright © 2021 Lynnesbian under the GPL3 (or later) License.",
before_long_help = "Copyright © 2021 Lynnesbian\n\
This program is free software: you can redistribute it and/or modify \
it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 \
of the License, or (at your option) any later version.",
setting(AppSettings::ColoredHelp)
)]
pub struct Parameters { pub struct Parameters {
/// Only examine files with these extensions (Comma-separated list) /// Only examine files with these extensions (Comma-separated list)
#[clap( #[clap(
@ -35,7 +47,7 @@ pub struct Parameters {
#[clap(short, long)] #[clap(short, long)]
pub scan_hidden: bool, pub scan_hidden: bool,
/// Output format to use. See "--help formats" for more information. /// Output format to use
#[clap(short, long, default_value = "script", arg_enum)] #[clap(short, long, default_value = "script", arg_enum)]
pub output_format: OutputFormat, pub output_format: OutputFormat,

View file

@ -19,7 +19,7 @@ impl Display for ScanError {
Self::Mime(_) => "determine mime type of", Self::Mime(_) => "determine mime type of",
}, },
match self { match self {
Self::File(f) | Self::Mime(f) => f.to_string_lossy() Self::File(f) | Self::Mime(f) => f.to_string_lossy(),
} }
) )
} }