mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:38:11 +00:00
seq: Add the --separator option
This commit is contained in:
parent
d16fa32674
commit
956ef0c9fd
1 changed files with 4 additions and 1 deletions
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <AK/Format.h>
|
#include <AK/Format.h>
|
||||||
#include <AK/StdLibExtras.h>
|
#include <AK/StdLibExtras.h>
|
||||||
|
#include <AK/String.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <LibCore/System.h>
|
#include <LibCore/System.h>
|
||||||
|
@ -48,9 +49,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
TRY(Core::System::pledge("stdio"));
|
TRY(Core::System::pledge("stdio"));
|
||||||
TRY(Core::System::unveil(nullptr, nullptr));
|
TRY(Core::System::unveil(nullptr, nullptr));
|
||||||
|
|
||||||
|
StringView separator = "\n"sv;
|
||||||
Vector<char const*> parameters;
|
Vector<char const*> parameters;
|
||||||
|
|
||||||
Core::ArgsParser args_parser;
|
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.add_positional_argument(parameters, "1 to 3 parameters, interpreted as LAST, FIRST LAST, or FIRST INCREMENT LAST", "parameters");
|
||||||
args_parser.parse(arguments);
|
args_parser.parse(arguments);
|
||||||
|
|
||||||
|
@ -98,7 +101,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
else if ((dot - buf) + 1 + number_of_decimals < (int)sizeof(buf))
|
else if ((dot - buf) + 1 + number_of_decimals < (int)sizeof(buf))
|
||||||
dot[1 + number_of_decimals] = '\0';
|
dot[1 + number_of_decimals] = '\0';
|
||||||
}
|
}
|
||||||
outln("{}", buf);
|
out("{}{}", buf, separator);
|
||||||
d += step;
|
d += step;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue