Skip to content

Commit 9d48ef5

Browse files
committed
Misc. changes
1 parent 758a4d4 commit 9d48ef5

File tree

2 files changed

+20
-25
lines changed

2 files changed

+20
-25
lines changed

src/cmd_nwr/comment.rs

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ pub fn make_subcommand() -> Command {
124124
.long("remove")
125125
.short('r')
126126
.num_args(1)
127-
.action(ArgAction::Append)
128127
.help("Scan all nodes and remove parts of comments matching the regex"),
129128
)
130129
.arg(
@@ -238,26 +237,25 @@ pub fn execute(args: &ArgMatches) -> anyhow::Result<()> {
238237

239238
// ids matched with --remove
240239
if args.contains_id("remove") {
241-
for regex in args.get_many::<String>("remove").unwrap() {
242-
let re = regex::RegexBuilder::new(regex)
243-
.case_insensitive(true)
244-
.unicode(false)
245-
.build()
246-
.unwrap();
247-
for (id, comment) in comment_of.iter() {
248-
let parts: Vec<_> = comment.split(':').collect();
249-
let new = parts
250-
.iter()
251-
.filter(|e| !re.is_match(e))
252-
.map(|e| *e)
253-
.collect::<Vec<_>>()
254-
.join(":");
255-
let node = tree.get_mut(id).unwrap();
256-
if new.is_empty() {
257-
node.comment = None;
258-
} else {
259-
node.comment = Some(new);
260-
}
240+
let regex = args.get_one::<String>("remove").unwrap();
241+
let re = regex::RegexBuilder::new(regex)
242+
.case_insensitive(true)
243+
.unicode(false)
244+
.build()
245+
.unwrap();
246+
for (id, comment) in comment_of.iter() {
247+
let parts: Vec<_> = comment.split(':').collect();
248+
let new = parts
249+
.iter()
250+
.filter(|e| !re.is_match(e))
251+
.map(|e| *e)
252+
.collect::<Vec<_>>()
253+
.join(":");
254+
let node = tree.get_mut(id).unwrap();
255+
if new.is_empty() {
256+
node.comment = None;
257+
} else {
258+
node.comment = Some(new);
261259
}
262260
}
263261
}

tests/cli_newick_visualization.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,7 @@ fn command_comment_remove() -> anyhow::Result<()> {
7070
.unwrap();
7171
let stdout = String::from_utf8(output.stdout).unwrap();
7272

73-
assert_eq!(
74-
stdout.lines().next().unwrap(),
75-
"((A,B)[dot=black],C);"
76-
);
73+
assert_eq!(stdout.lines().next().unwrap(), "((A,B)[dot=black],C);");
7774

7875
Ok(())
7976
}

0 commit comments

Comments
 (0)