From 956ef0c9fdb9cbbe78e4918230daf03431c26dc6 Mon Sep 17 00:00:00 2001 From: Eli Youngs Date: Sun, 23 Oct 2022 18:30:06 -0700 Subject: [PATCH] seq: Add the --separator option --- Userland/Utilities/seq.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Userland/Utilities/seq.cpp b/Userland/Utilities/seq.cpp index 443ea76062..6000e03f3d 100644 --- a/Userland/Utilities/seq.cpp +++ b/Userland/Utilities/seq.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -48,9 +49,11 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio")); TRY(Core::System::unveil(nullptr, nullptr)); + StringView separator = "\n"sv; Vector parameters; Core::ArgsParser args_parser; + args_parser.add_option(separator, "Characters to print after each number (default: \\n)", "separator", 's', "separator"); args_parser.add_positional_argument(parameters, "1 to 3 parameters, interpreted as LAST, FIRST LAST, or FIRST INCREMENT LAST", "parameters"); args_parser.parse(arguments); @@ -98,7 +101,7 @@ ErrorOr serenity_main(Main::Arguments arguments) else if ((dot - buf) + 1 + number_of_decimals < (int)sizeof(buf)) dot[1 + number_of_decimals] = '\0'; } - outln("{}", buf); + out("{}{}", buf, separator); d += step; }