mirror of
https://github.com/SinTan1729/movie-rename.git
synced 2024-12-26 12:18:37 -06:00
Added manpage
This commit is contained in:
parent
408824aca9
commit
d6f6425a0d
3 changed files with 57 additions and 9 deletions
|
@ -1,13 +1,13 @@
|
||||||
# movie-rename
|
# 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.
|
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:
|
The expected syntax is:
|
||||||
|
|
||||||
`movie_rename <filename(s)> [--dry-run] [--directory] [--help]`
|
`movie_rename <filename(s)> [-n|--dry-run] [-d|--directory] [-h|--help] [-v|--version]`
|
||||||
- There needs to be a config file names movie_rename.conf in your $XDG_CONFIG_HOME.
|
- 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.
|
- 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.
|
- 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`.
|
- In the pattern, the variables need to be enclosed in {{}}, the supported variables are `title`, `year` and `director`.
|
||||||
|
|
37
movie_rename.1
Normal file
37
movie_rename.1
Normal file
|
@ -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 <filename(s)> [-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
|
23
src/main.rs
23
src/main.rs
|
@ -4,6 +4,7 @@ use tmdb::{model::*, themoviedb::*};
|
||||||
use torrent_name_parser::Metadata;
|
use torrent_name_parser::Metadata;
|
||||||
use youchoose;
|
use youchoose;
|
||||||
|
|
||||||
|
const VERSION: &str = "1.1.1";
|
||||||
// Struct for movie entries
|
// Struct for movie entries
|
||||||
struct MovieEntry {
|
struct MovieEntry {
|
||||||
title: String,
|
title: String,
|
||||||
|
@ -259,9 +260,11 @@ fn process_args(mut args: Vec<String>) -> (Vec<String>, HashMap<&'static str, bo
|
||||||
let mut settings = HashMap::from([("dry_run", false), ("directory", false)]);
|
let mut settings = HashMap::from([("dry_run", false), ("directory", false)]);
|
||||||
for arg in args {
|
for arg in args {
|
||||||
match arg.as_str() {
|
match arg.as_str() {
|
||||||
"--help" => {
|
"--help" | "-h" => {
|
||||||
println!(" The expected syntax is:");
|
println!(" The expected syntax is:");
|
||||||
println!(" movie_rename <filename(s)> [--dry-run] [--directory]");
|
println!(
|
||||||
|
" movie_rename <filename(s)> [-n|--dry-run] [-d|--directory] [-v|--version]"
|
||||||
|
);
|
||||||
println!(
|
println!(
|
||||||
" There needs to be a config file names movie_rename.conf in your $XDG_CONFIG_HOME."
|
" 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<String>) -> (Vec<String>, HashMap<&'static str, bo
|
||||||
println!(" Pass --help to get this again.");
|
println!(" Pass --help to get this again.");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
"--dry-run" => {
|
"--dry-run" | "-n" => {
|
||||||
println!("Doing a dry run...");
|
println!("Doing a dry run...");
|
||||||
settings.entry("dry_run").and_modify(|x| *x = true);
|
settings.entry("dry_run").and_modify(|x| *x = true);
|
||||||
}
|
}
|
||||||
"--directory" => {
|
"--directory" | "-d" => {
|
||||||
println!("Running in directory mode...");
|
println!("Running in directory mode...");
|
||||||
settings.entry("directory").and_modify(|x| *x = true);
|
settings.entry("directory").and_modify(|x| *x = true);
|
||||||
}
|
}
|
||||||
_ => {
|
"--version" | "-v" => {
|
||||||
entries.push(arg);
|
println!("{}", VERSION);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
other => {
|
||||||
|
if other.contains("-") {
|
||||||
|
eprintln!("Unknown argument passed: {}", other);
|
||||||
|
} else {
|
||||||
|
entries.push(arg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue