Improve imdl torrent create flags

Add short flags and make some long flags shorter.

type: added
This commit is contained in:
Casey Rodarmor 2020-03-09 00:43:12 -07:00
parent 3276f2d043
commit 21a87a46f3
No known key found for this signature in database
GPG Key ID: 556186B153EC6FE0

View File

@ -9,6 +9,7 @@ use crate::common::*;
pub(crate) struct Create { pub(crate) struct Create {
#[structopt( #[structopt(
long = "announce", long = "announce",
short = "a",
value_name = "URL", value_name = "URL",
required(true), required(true),
help = "Use `URL` as the primary tracker announce URL. To supply multiple announce URLs, also \ help = "Use `URL` as the primary tracker announce URL. To supply multiple announce URLs, also \
@ -17,6 +18,7 @@ pub(crate) struct Create {
announce: Url, announce: Url,
#[structopt( #[structopt(
long = "allow", long = "allow",
short = "A",
value_name = "LINT", value_name = "LINT",
possible_values = Lint::VALUES, possible_values = Lint::VALUES,
help = "Allow `LINT`. Lints check for conditions which, although permitted, are not usually \ help = "Allow `LINT`. Lints check for conditions which, although permitted, are not usually \
@ -27,6 +29,7 @@ pub(crate) struct Create {
allowed_lints: Vec<Lint>, allowed_lints: Vec<Lint>,
#[structopt( #[structopt(
long = "announce-tier", long = "announce-tier",
short = "t",
value_name = "URL-LIST", value_name = "URL-LIST",
help = "Use `URL-LIST` as a tracker announce tier. Each instance adds a new \ help = "Use `URL-LIST` as a tracker announce tier. Each instance adds a new \
tier. To add multiple trackers to a given tier, separate their announce URLs \ tier. To add multiple trackers to a given tier, separate their announce URLs \
@ -45,35 +48,40 @@ pub(crate) struct Create {
announce_tiers: Vec<String>, announce_tiers: Vec<String>,
#[structopt( #[structopt(
long = "comment", long = "comment",
short = "c",
value_name = "TEXT", value_name = "TEXT",
help = "Include `TEXT` as the comment for generated `.torrent` file. Stored under `comment` \ help = "Include `TEXT` as the comment for generated `.torrent` file. Stored under `comment` \
key of top-level metainfo dictionary." key of top-level metainfo dictionary."
)] )]
comment: Option<String>, comment: Option<String>,
#[structopt( #[structopt(
long = "dht-node", long = "node",
short = "n",
value_name = "NODE", value_name = "NODE",
help = "Add DHT bootstrap node `NODE` to torrent. `NODE` should be in the form `HOST:PORT`, \ help = "Add DHT bootstrap node `NODE` to torrent. `NODE` should be in the form `HOST:PORT`, \
where `HOST` is a domain name, an IPv4 address, or an IPv6 address surrounded by \ where `HOST` is a domain name, an IPv4 address, or an IPv6 address surrounded by \
brackets. May be given more than once to add multiple bootstrap nodes. Examples: brackets. May be given more than once to add multiple bootstrap nodes. Examples:
`--dht-node router.example.com:1337` `--node router.example.com:1337`
`--dht-node 203.0.113.0:2290` `--node 203.0.113.0:2290`
`--dht-node [2001:db8:4275:7920:6269:7463:6f69:6e21]:8832`" `--node [2001:db8:4275:7920:6269:7463:6f69:6e21]:8832`"
)] )]
dht_nodes: Vec<Node>, dht_nodes: Vec<Node>,
#[structopt( #[structopt(
long = "follow-symlinks", long = "follow-symlinks",
short = "F",
help = "Follow symlinks in torrent input. By default, symlinks to files and directories are \ help = "Follow symlinks in torrent input. By default, symlinks to files and directories are \
not included in torrent contents." not included in torrent contents."
)] )]
follow_symlinks: bool, follow_symlinks: bool,
#[structopt( #[structopt(
long = "force", long = "force",
short = "f",
help = "Overwrite the destination `.torrent` file, if it exists." help = "Overwrite the destination `.torrent` file, if it exists."
)] )]
force: bool, force: bool,
#[structopt( #[structopt(
long = "glob", long = "glob",
short = "g",
value_name = "GLOB", value_name = "GLOB",
help = "Include or exclude files that match `GLOB`. Multiple glob may be provided, with the \ help = "Include or exclude files that match `GLOB`. Multiple glob may be provided, with the \
last one taking precedence. Precede a glob with `!` to exclude it." last one taking precedence. Precede a glob with `!` to exclude it."
@ -81,17 +89,20 @@ pub(crate) struct Create {
globs: Vec<String>, globs: Vec<String>,
#[structopt( #[structopt(
long = "include-hidden", long = "include-hidden",
short = "h",
help = "Include hidden files that would otherwise be skipped, such as files that start with a \ help = "Include hidden files that would otherwise be skipped, such as files that start with a \
`.`, and files hidden by file attributes on macOS and Windows." `.`, and files hidden by file attributes on macOS and Windows."
)] )]
include_hidden: bool, include_hidden: bool,
#[structopt( #[structopt(
long = "include-junk", long = "include-junk",
short = "j",
help = "Include junk files that would otherwise be skipped." help = "Include junk files that would otherwise be skipped."
)] )]
include_junk: bool, include_junk: bool,
#[structopt( #[structopt(
long = "input", long = "input",
short = "i",
value_name = "PATH", value_name = "PATH",
help = "Read torrent contents from `PATH`. If `PATH` is a file, torrent will be a single-file \ help = "Read torrent contents from `PATH`. If `PATH` is a file, torrent will be a single-file \
torrent, if `PATH` is a directory, torrent will be a multi-file torrent.", torrent, if `PATH` is a directory, torrent will be a multi-file torrent.",
@ -99,13 +110,15 @@ pub(crate) struct Create {
)] )]
input: PathBuf, input: PathBuf,
#[structopt( #[structopt(
long = "md5sum", long = "md5",
short = "M",
help = "Include MD5 checksum of each file in the torrent. N.B. MD5 is cryptographically \ help = "Include MD5 checksum of each file in the torrent. N.B. MD5 is cryptographically \
broken and only suitable for checking for accidental corruption." broken and only suitable for checking for accidental corruption."
)] )]
md5sum: bool, md5sum: bool,
#[structopt( #[structopt(
long = "name", long = "name",
short = "N",
value_name = "TEXT", value_name = "TEXT",
help = "Set name of torrent to `TEXT`. Defaults to the filename of the argument to `--input`." help = "Set name of torrent to `TEXT`. Defaults to the filename of the argument to `--input`."
)] )]
@ -122,12 +135,14 @@ pub(crate) struct Create {
no_creation_date: bool, no_creation_date: bool,
#[structopt( #[structopt(
long = "open", long = "open",
short = "O",
help = "Open `.torrent` file after creation. Uses `xdg-open`, `gnome-open`, or `kde-open` on \ help = "Open `.torrent` file after creation. Uses `xdg-open`, `gnome-open`, or `kde-open` on \
Linux; `open` on macOS; and `cmd /C start on Windows" Linux; `open` on macOS; and `cmd /C start on Windows"
)] )]
open: bool, open: bool,
#[structopt( #[structopt(
long = "output", long = "output",
short = "o",
value_name = "TARGET", value_name = "TARGET",
help = "Save `.torrent` file to `TARGET`, or print to standard output if `TARGET` is `-`. \ help = "Save `.torrent` file to `TARGET`, or print to standard output if `TARGET` is `-`. \
Defaults to `$INPUT.torrent`.", Defaults to `$INPUT.torrent`.",
@ -136,12 +151,14 @@ pub(crate) struct Create {
output: Option<Target>, output: Option<Target>,
#[structopt( #[structopt(
long = "piece-length", long = "piece-length",
short = "p",
value_name = "BYTES", value_name = "BYTES",
help = "Set piece length to `BYTES`. Accepts SI units, e.g. kib, mib, and gib." help = "Set piece length to `BYTES`. Accepts SI units, e.g. kib, mib, and gib."
)] )]
piece_length: Option<Bytes>, piece_length: Option<Bytes>,
#[structopt( #[structopt(
long = "private", long = "private",
short = "P",
help = "Set the `private` flag. Torrent clients that understand the flag and participate in \ help = "Set the `private` flag. Torrent clients that understand the flag and participate in \
the swarm of a torrent with the flag set will only announce themselves to the \ the swarm of a torrent with the flag set will only announce themselves to the \
announce URLs included in the torrent, and will not use other peer discovery \ announce URLs included in the torrent, and will not use other peer discovery \
@ -151,6 +168,7 @@ pub(crate) struct Create {
private: bool, private: bool,
#[structopt( #[structopt(
long = "source", long = "source",
short = "s",
value_name = "TEXT", value_name = "TEXT",
help = "Set torrent source to `TEXT`. Stored under `source` key of info dictionary. This is \ help = "Set torrent source to `TEXT`. Stored under `source` key of info dictionary. This is \
useful for keeping statistics from being mis-reported when participating in swarms \ useful for keeping statistics from being mis-reported when participating in swarms \
@ -971,7 +989,7 @@ mod tests {
"small-piece-length", "small-piece-length",
"--piece-length", "--piece-length",
"8", "8",
"--md5sum", "--md5",
], ],
tree: { tree: {
dir: { dir: {
@ -1121,7 +1139,7 @@ mod tests {
"foo", "foo",
"--announce", "--announce",
"http://bar", "http://bar",
"--md5sum", "--md5",
], ],
tree: { tree: {
foo: { foo: {
@ -1192,7 +1210,7 @@ mod tests {
"foo", "foo",
"--announce", "--announce",
"http://bar", "http://bar",
"--md5sum" "--md5"
], ],
tree: { tree: {
foo: { foo: {
@ -1699,7 +1717,7 @@ Content Size 9 bytes
"foo", "foo",
"--announce", "--announce",
"http://bar", "http://bar",
"--md5sum", "--md5",
], ],
tree: {}, tree: {},
}; };
@ -1725,7 +1743,7 @@ Content Size 9 bytes
"--announce", "--announce",
"http://bar", "http://bar",
"--follow-symlinks", "--follow-symlinks",
"--md5sum", "--md5",
], ],
tree: {}, tree: {},
}; };
@ -1768,7 +1786,7 @@ Content Size 9 bytes
"foo", "foo",
"--announce", "--announce",
"http://bar", "http://bar",
"--md5sum", "--md5",
], ],
tree: {}, tree: {},
}; };
@ -1796,7 +1814,7 @@ Content Size 9 bytes
"foo", "foo",
"--announce", "--announce",
"http://bar", "http://bar",
"--md5sum", "--md5",
], ],
tree: { tree: {
foo: { foo: {
@ -1825,7 +1843,7 @@ Content Size 9 bytes
"foo", "foo",
"--announce", "--announce",
"http://bar", "http://bar",
"--md5sum" "--md5"
], ],
tree: { tree: {
foo: { foo: {
@ -2056,7 +2074,7 @@ Content Size 9 bytes
"foo", "foo",
"--announce", "--announce",
"http://bar", "http://bar",
"--dht-node", "--node",
"blah", "blah",
], ],
tree: { tree: {
@ -2076,11 +2094,11 @@ Content Size 9 bytes
"foo", "foo",
"--announce", "--announce",
"http://bar", "http://bar",
"--dht-node", "--node",
"router.example.com:1337", "router.example.com:1337",
"--dht-node", "--node",
"203.0.113.0:2290", "203.0.113.0:2290",
"--dht-node", "--node",
"[2001:db8:4275:7920:6269:7463:6f69:6e21]:8832", "[2001:db8:4275:7920:6269:7463:6f69:6e21]:8832",
], ],
tree: { tree: {