better documentation for parameters, renamed Script to Sh

This commit is contained in:
Lynne Megido 2021-04-07 01:47:40 +10:00
parent cb2a30f455
commit be37b24705
Signed by: lynnesbian
GPG key ID: F0A184B5213D9F90
2 changed files with 19 additions and 10 deletions

View file

@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#![forbid(unsafe_code)]
use std::io::{stdout, BufWriter};
use std::path::Path;
@ -130,7 +132,7 @@ fn main() {
let mut buffered_stdout = BufWriter::new(stdout());
let result = match args.output_format {
OutputFormat::Script => Script::new().write_all(&results, &mut buffered_stdout),
OutputFormat::Sh => Script::new().write_all(&results, &mut buffered_stdout),
OutputFormat::PowerShell | OutputFormat::Powershell => PowerShell::new().write_all(&results, &mut buffered_stdout),
OutputFormat::Text => todo!(),
};

View file

@ -10,14 +10,14 @@ cfg_if! {
if #[cfg(windows)] {
const DEFAULT_FORMAT: &str = "powershell";
} else {
const DEFAULT_FORMAT: &str = "script";
const DEFAULT_FORMAT: &str = "sh";
}
}
#[derive(Clap, PartialEq, Debug)]
pub enum OutputFormat {
/// A Bourne shell compatible script.
Script,
Sh,
/// A PowerShell script.
PowerShell,
/// Also a PowerShell script, with different casing to allow for `fif -o powershell`.
@ -41,31 +41,38 @@ pub enum OutputFormat {
setting(AppSettings::ColoredHelp)
)]
pub struct Parameters {
/// Only examine files with these extensions (Comma-separated list)
/// Only examine files with these extensions (Comma-separated list).
/// This argument conflicts with `-E`.
#[clap(short, long, use_delimiter = true, require_delimiter = true, group = "extensions")]
pub exts: Option<Vec<StringType>>,
/// Use a preset list of extensions as the search filter
/// Use a preset list of extensions as the search filter.
/// `media` includes all extensions from the `audio`, `video`, and `images` sets. This argument conflicts with `-e`.
#[clap(short = 'E', long, arg_enum, group = "extensions")]
pub ext_set: Option<ExtensionSet>,
/// Don't skip hidden files and directories
/// Don't skip hidden files and directories.
/// Even if this flag is not present, fif will still recurse into a hidden root directory - for example, `fif
/// ~/.hidden` will recurse into `~/.hidden` regardless of whether or not -s was passed as an argument.
#[clap(short, long)]
pub scan_hidden: bool,
/// Scan files without extensions
/// Scan files without extensions.
/// By default, fif will ignore files without extensions - for example, a jpeg file named `photo` won't be considered
/// misnamed. Supplying the -S flag will cause fif to recommend renaming this file to `photo.jpg`.
#[clap(short = 'S', long)]
pub scan_extensionless: bool,
/// Output format to use
/// 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)]
pub output_format: OutputFormat,
/// Follow symlinks
/// Follow symlinks.
#[clap(short, long)]
pub follow_symlinks: bool,
/// Directory to process
/// 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))]
pub dirs: PathBuf,