Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions seq/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ pub(crate) fn create_app<'a, 'b>() -> App<'a, 'b> {
.hide_default_value(true)
.default_value("\n"),
)
.arg(
Arg::with_name("TERMINATOR")
.short("t")
.long("terminator")
.help("Terminator of the values.")
.hide_default_value(true)
.default_value("\n"),
)
.arg(
Arg::with_name("WIDTH")
.short("w")
Expand Down
3 changes: 2 additions & 1 deletion seq/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ fn main() {
let decimals = max_decimal_digits(&args);
let padding = if matches.is_present("WIDTH") { Some(max_digits(&args)) } else { None };
let (first, inc, last) = find_operands(&args);
let terminator = matches.value_of("TERMINATOR").unwrap_or("\n");
let valid_range = (first <= last && inc > 0.0) || (first >= last && inc < 0.0);
if valid_range {
let seq = Seq::new(first, inc, last, decimals, separator, padding);
for val in seq.into_iter() {
print!("{}", val);
}
println!();
print!("{}", terminator);
}
} else {
eprintln!("seq: missing operand\n Try 'seq --help' for more information.");
Expand Down