Skip to content

Commit

Permalink
Make less Command clones
Browse files Browse the repository at this point in the history
  • Loading branch information
janos committed Jan 7, 2024
1 parent d657274 commit a12a394
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/bin/casbab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use clap::{arg, error::ErrorKind, Command};
use std::io;

fn main() {
let cmd = Command::new("casbab")
let mut cmd = Command::new("casbab")
.about("Camel Snake Kebab (https://github.com/janos/casbab-rs)")
.disable_version_flag(true)
.arg_required_else_help(true)
Expand Down Expand Up @@ -55,21 +55,19 @@ Stdin as the new-line separated list.
"title " => casbab::title,
"screaming" => casbab::screaming,
_ => {
cmd.clone()
.error(ErrorKind::InvalidSubcommand, "Invalid dialect")
cmd.error(ErrorKind::InvalidSubcommand, "Invalid dialect")
.exit();
}
};

let phrases: Vec<String> = match matches.get_many("phrases") {
None => {
if atty::is(Stream::Stdin) {
cmd.clone()
.error(
ErrorKind::InvalidValue,
"Missing phases either from arguments or stdin",
)
.exit();
cmd.error(
ErrorKind::InvalidValue,
"Missing phases either from arguments or stdin",
)
.exit();
}
let mut phrases: Vec<String> = Vec::new();
for line in io::stdin().lines() {
Expand Down

0 comments on commit a12a394

Please sign in to comment.