From d6f6425a0d41ae8037813718feddd77dfa9b35c9 Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Thu, 8 Dec 2022 21:59:53 -0600 Subject: [PATCH] Added manpage --- README.md | 6 +++--- movie_rename.1 | 37 +++++++++++++++++++++++++++++++++++++ src/main.rs | 23 +++++++++++++++++------ 3 files changed, 57 insertions(+), 9 deletions(-) create mode 100644 movie_rename.1 diff --git a/README.md b/README.md index 8eaee01..15a015f 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ # movie-rename -## A simple tool to reame movies, written in Rust. +## A simple tool to rename movies, written in Rust. This is made mostly due to [mnamer](https://github.com/jkwill87/mnamer) not having support for director's name, and partly because I wanted to try writing something useful in Rust. The expected syntax is: -`movie_rename [--dry-run] [--directory] [--help]` -- There needs to be a config file names movie_rename.conf in your $XDG_CONFIG_HOME. +`movie_rename [-n|--dry-run] [-d|--directory] [-h|--help] [-v|--version]` +- There needs to be a config file named movie_rename.conf in your $XDG_CONFIG_HOME. - It should consist of two lines. The first line should have your TMDb API key. - The second line should have a pattern, that will be used for the rename. - In the pattern, the variables need to be enclosed in {{}}, the supported variables are `title`, `year` and `director`. diff --git a/movie_rename.1 b/movie_rename.1 new file mode 100644 index 0000000..afc3eb2 --- /dev/null +++ b/movie_rename.1 @@ -0,0 +1,37 @@ +.\" Manpage for movie_rename. +.\" Contact sayantan[dot]santra689[at]gmail[dot]com to correct errors or typos. +.TH man 1 "08 Dec 2022" "1.1.1" "movie_rename man page" +.SH NAME +movie_rename +.SH SYNOPSIS +movie_rename [-n|--dry-run] [-d|--directory] [-h|--help] [-v|--version] +.SH DESCRIPTION +movie_rename is a simple tool to rename movies, written in Rust. +.SH ARGUMENTS +A list of filenames (or directory names, not both). -d or --directory must be passed to work with directories. +.SH OPTIONS +.TP +-n, --dry-run +Performs a dry run, without actually renaming anything. +.TP +-d. --directory +Runs in directory mode. In this mode, it is assumed that the arguments are directory names, which contain exactly one movie and optionally subtitles. +.TP +-h, --help +Print help information. +.TP +-v, --version +Print version information. +.SH CONFIG +There needs to be a config file named movie_rename.conf in your $XDG_CONFIG_HOME. +It should consist of two lines. +.sp +The first line should have your TMDb API key. +.sp +The second line should have a pattern, that will be used for the rename. +.sp +In the pattern, the variables need to be enclosed in {}, the supported variables are `title`, `year` and `director`. +.sp +Default pattern is `{title} ({year}) - {director}`. Extension is always kept. +.SH AUTHOR +Sayantan Santra sayantan[dot]santra689[at]gmail[dot]com diff --git a/src/main.rs b/src/main.rs index 462266f..abc6632 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,7 @@ use tmdb::{model::*, themoviedb::*}; use torrent_name_parser::Metadata; use youchoose; +const VERSION: &str = "1.1.1"; // Struct for movie entries struct MovieEntry { title: String, @@ -259,9 +260,11 @@ fn process_args(mut args: Vec) -> (Vec, HashMap<&'static str, bo let mut settings = HashMap::from([("dry_run", false), ("directory", false)]); for arg in args { match arg.as_str() { - "--help" => { + "--help" | "-h" => { println!(" The expected syntax is:"); - println!(" movie_rename [--dry-run] [--directory]"); + println!( + " movie_rename [-n|--dry-run] [-d|--directory] [-v|--version]" + ); println!( " There needs to be a config file names movie_rename.conf in your $XDG_CONFIG_HOME." ); @@ -277,16 +280,24 @@ fn process_args(mut args: Vec) -> (Vec, HashMap<&'static str, bo println!(" Pass --help to get this again."); exit(0); } - "--dry-run" => { + "--dry-run" | "-n" => { println!("Doing a dry run..."); settings.entry("dry_run").and_modify(|x| *x = true); } - "--directory" => { + "--directory" | "-d" => { println!("Running in directory mode..."); settings.entry("directory").and_modify(|x| *x = true); } - _ => { - entries.push(arg); + "--version" | "-v" => { + println!("{}", VERSION); + exit(0); + } + other => { + if other.contains("-") { + eprintln!("Unknown argument passed: {}", other); + } else { + entries.push(arg); + } } } }