mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:37:34 +00:00
Userland: Use Core::ArgsParser for 'tr'
This commit is contained in:
parent
559ea8e1b5
commit
d320f7b9d2
1 changed files with 11 additions and 6 deletions
|
@ -27,18 +27,23 @@
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <AK/QuickSort.h>
|
#include <AK/QuickSort.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if (argc != 3) {
|
const char* from_chars = nullptr;
|
||||||
printf("usage: tr <from> <to>");
|
const char* to_chars = nullptr;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
char from = argv[1][0];
|
Core::ArgsParser args_parser;
|
||||||
char to = argv[2][0];
|
args_parser.add_positional_argument(from_chars, "Character to translate from", "from");
|
||||||
|
args_parser.add_positional_argument(to_chars, "Character to translate to", "to");
|
||||||
|
args_parser.parse(argc, argv);
|
||||||
|
|
||||||
|
// TODO: Support multiple characters to translate from and to
|
||||||
|
auto from = from_chars[0];
|
||||||
|
auto to = to_chars[0];
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
char ch = fgetc(stdin);
|
char ch = fgetc(stdin);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue