Fix help strings
Fix inconsistent argument value names in help strings. type: fixed
This commit is contained in:
parent
ebec2d591a
commit
cecd2f66a5
|
@ -4,7 +4,8 @@ Changelog
|
|||
|
||||
UNRELEASED - 2020-04-22
|
||||
-----------------------
|
||||
- :zap: [`xxxxxxxxxxxx`](https://github.com/casey/intermodal/commits/master) Allow positional shell to `imdl completions` - Fixes [#375](https://github.com/casey/intermodal/issues/375) - _Casey Rodarmor <casey@rodarmor.com>_
|
||||
- :bug: [`xxxxxxxxxxxx`](https://github.com/casey/intermodal/commits/master) Fix help strings - _Casey Rodarmor <casey@rodarmor.com>_
|
||||
- :zap: [`ebec2d591a7a`](https://github.com/casey/intermodal/commit/ebec2d591a7a0e2a2c4cd55217db4ba46b5dd9ed) Allow positional shell to `imdl completions` - Fixes [#375](https://github.com/casey/intermodal/issues/375) - _Casey Rodarmor <casey@rodarmor.com>_
|
||||
- :art: [`134c241ae7f8`](https://github.com/casey/intermodal/commit/134c241ae7f8e374d8a9266e7eb0c4a9c3844c30) Use `lexiclean` crate for lexical path cleaning - _Casey Rodarmor <casey@rodarmor.com>_
|
||||
- :zap: [`323434d0aa21`](https://github.com/casey/intermodal/commit/323434d0aa21ebfda5be85ecd4a38a55ed3fec0a) Allow positional input to `imdl torrent verify` - Fixes [#375](https://github.com/casey/intermodal/issues/375) - _Casey Rodarmor <casey@rodarmor.com>_
|
||||
- :zap: [`5ba885dbc4f2`](https://github.com/casey/intermodal/commit/5ba885dbc4f24781d6a3240ddfc0c03177b12f1e) Take input to `imdl torrent create` as positional - Fixes [#375](https://github.com/casey/intermodal/issues/375) - _Casey Rodarmor <casey@rodarmor.com>_
|
||||
|
|
|
@ -5,9 +5,9 @@ use create_step::CreateStep;
|
|||
mod create_content;
|
||||
mod create_step;
|
||||
|
||||
const INPUT_HELP: &str = "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. If `PATH` is `-`, read from standard input. Piece \
|
||||
const INPUT_HELP: &str = "Read torrent contents from `INPUT`. If `INPUT` is a file, torrent will \
|
||||
be a single-file torrent. If `INPUT` is a directory, torrent will be a \
|
||||
multi-file torrent. If `INPUT` is `-`, read from standard input. Piece \
|
||||
length defaults to 256KiB when reading from standard input if \
|
||||
`--piece-length` is not given.";
|
||||
|
||||
|
@ -138,7 +138,7 @@ Examples:
|
|||
name = INPUT_FLAG,
|
||||
long = "input",
|
||||
short = "i",
|
||||
value_name = "PATH",
|
||||
value_name = "INPUT",
|
||||
empty_values = false,
|
||||
parse(try_from_os_str = InputTarget::try_from_os_str),
|
||||
help = INPUT_HELP,
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
use crate::common::*;
|
||||
|
||||
const INPUT_HELP: &str = "Generate magnet link from metainfo at `INPUT`. If `INPUT` is `-`, read \
|
||||
metainfo from standard input.";
|
||||
|
||||
const INPUT_FLAG: &str = "input-flag";
|
||||
|
||||
const INPUT_POSITIONAL: &str = "<INPUT>";
|
||||
|
||||
#[derive(StructOpt)]
|
||||
#[structopt(
|
||||
help_message(consts::HELP_MESSAGE),
|
||||
|
@ -8,15 +15,25 @@ use crate::common::*;
|
|||
)]
|
||||
pub(crate) struct Link {
|
||||
#[structopt(
|
||||
name = INPUT_FLAG,
|
||||
long = "input",
|
||||
short = "i",
|
||||
value_name = "METAINFO",
|
||||
value_name = "INPUT",
|
||||
empty_values(false),
|
||||
parse(try_from_os_str = InputTarget::try_from_os_str),
|
||||
help = "Generate magnet link from metainfo at `PATH`. If `PATH` is `-`, read metainfo from \
|
||||
standard input.",
|
||||
help = INPUT_HELP,
|
||||
)]
|
||||
input: InputTarget,
|
||||
input_flag: Option<InputTarget>,
|
||||
#[structopt(
|
||||
name = INPUT_POSITIONAL,
|
||||
value_name = "INPUT",
|
||||
empty_values(false),
|
||||
parse(try_from_os_str = InputTarget::try_from_os_str),
|
||||
required_unless = INPUT_FLAG,
|
||||
conflicts_with = INPUT_FLAG,
|
||||
help = INPUT_HELP,
|
||||
)]
|
||||
input_positional: Option<InputTarget>,
|
||||
#[structopt(
|
||||
long = "open",
|
||||
short = "O",
|
||||
|
@ -44,7 +61,14 @@ pub(crate) struct Link {
|
|||
|
||||
impl Link {
|
||||
pub(crate) fn run(self, env: &mut Env) -> Result<(), Error> {
|
||||
let input = env.read(self.input.clone())?;
|
||||
let input = xor_args(
|
||||
"input_flag",
|
||||
&self.input_flag,
|
||||
"input_positional",
|
||||
&self.input_positional,
|
||||
)?;
|
||||
|
||||
let input = env.read(input.clone())?;
|
||||
|
||||
let infohash = Infohash::from_input(&input)?;
|
||||
let metainfo = Metainfo::from_input(&input)?;
|
||||
|
@ -84,7 +108,56 @@ mod tests {
|
|||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn no_announce() {
|
||||
fn input_required() {
|
||||
test_env! {
|
||||
args: [
|
||||
"torrent",
|
||||
"link",
|
||||
],
|
||||
tree: {
|
||||
},
|
||||
matches: Err(Error::Clap { .. }),
|
||||
};
|
||||
|
||||
test_env! {
|
||||
args: [
|
||||
"torrent",
|
||||
"link",
|
||||
"--input",
|
||||
"foo",
|
||||
],
|
||||
tree: {
|
||||
},
|
||||
matches: Err(Error::Filesystem { .. }),
|
||||
};
|
||||
|
||||
test_env! {
|
||||
args: [
|
||||
"torrent",
|
||||
"link",
|
||||
"foo",
|
||||
],
|
||||
tree: {
|
||||
},
|
||||
matches: Err(Error::Filesystem { .. }),
|
||||
};
|
||||
|
||||
test_env! {
|
||||
args: [
|
||||
"torrent",
|
||||
"link",
|
||||
"--input",
|
||||
"foo",
|
||||
"foo",
|
||||
],
|
||||
tree: {
|
||||
},
|
||||
matches: Err(Error::Clap { .. }),
|
||||
};
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_announce_flag() {
|
||||
let mut env = test_env! {
|
||||
args: [
|
||||
"torrent",
|
||||
|
@ -109,6 +182,31 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_announce_positional() {
|
||||
let mut env = test_env! {
|
||||
args: [
|
||||
"torrent",
|
||||
"link",
|
||||
"foo.torrent",
|
||||
],
|
||||
tree: {
|
||||
"foo.torrent": "d4:infod6:lengthi0e4:name3:foo12:piece lengthi1e6:pieces0:ee",
|
||||
}
|
||||
};
|
||||
|
||||
env.assert_ok();
|
||||
|
||||
const INFO: &str = "d6:lengthi0e4:name3:foo12:piece lengthi1e6:pieces0:e";
|
||||
|
||||
let infohash = Sha1Digest::from_data(INFO.as_bytes());
|
||||
|
||||
assert_eq!(
|
||||
env.out(),
|
||||
format!("magnet:?xt=urn:btih:{}&dn=foo\n", infohash),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn with_announce() {
|
||||
let mut env = test_env! {
|
||||
|
|
|
@ -3,8 +3,8 @@ use verify_step::VerifyStep;
|
|||
|
||||
mod verify_step;
|
||||
|
||||
const METAINFO_HELP: &str = "Verify torrent contents against torrent metainfo in `METAINFO`. If \
|
||||
`METAINFO` is `-`, read metainfo from standard input.";
|
||||
const METAINFO_HELP: &str = "Verify torrent contents against torrent metainfo in `INPUT`. If \
|
||||
`INPUT` is `-`, read metainfo from standard input.";
|
||||
|
||||
const INPUT_POSITIONAL: &str = "<INPUT>";
|
||||
|
||||
|
@ -41,7 +41,7 @@ pub(crate) struct Verify {
|
|||
name = INPUT_FLAG,
|
||||
long = "input",
|
||||
short = "i",
|
||||
value_name = "METAINFO",
|
||||
value_name = "INPUT",
|
||||
empty_values = false,
|
||||
parse(try_from_os_str = InputTarget::try_from_os_str),
|
||||
help = METAINFO_HELP,
|
||||
|
|
|
@ -8,19 +8,29 @@ macro_rules! test_env {
|
|||
$(err_style: $err_style:expr,)?
|
||||
tree: {
|
||||
$($tree:tt)*
|
||||
} $(,)?
|
||||
}
|
||||
$(, matches: $result:pat)?
|
||||
|
||||
$(,)?
|
||||
} => {
|
||||
{
|
||||
let tempdir = temptree! { $($tree)* };
|
||||
|
||||
TestEnvBuilder::new()
|
||||
let env = TestEnvBuilder::new()
|
||||
$(.current_dir(tempdir.path().join($cwd)))?
|
||||
$(.err_style($err_style))?
|
||||
$(.input($input))?
|
||||
.tempdir(tempdir)
|
||||
.arg("imdl")
|
||||
$(.arg($arg))*
|
||||
.build()
|
||||
.build();
|
||||
|
||||
$(
|
||||
let mut env = env;
|
||||
assert_matches!(env.run(), $result);
|
||||
)?
|
||||
|
||||
env
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user