From ab1f3551cca414cefc3c4e14bbe0cd2fc21fff97 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Wed, 5 Aug 2020 21:09:35 +0200 Subject: [PATCH] Userland: Use Core::ArgsParser for 'md' --- Userland/md.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Userland/md.cpp b/Userland/md.cpp index f0b4268a14..f7dc74349b 100644 --- a/Userland/md.cpp +++ b/Userland/md.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -42,14 +43,12 @@ int main(int argc, char* argv[]) const char* file_name = nullptr; bool html = false; - for (int i = 1; i < argc; i++) - if (strcmp(argv[i], "--html") == 0) - html = true; - else - file_name = argv[i]; + Core::ArgsParser args_parser; + args_parser.add_option(html, "Render to HTML rather than for the terminal", "html", 'H'); + args_parser.add_positional_argument(file_name, "Path to Markdown file", "path", Core::ArgsParser::Required::No); + args_parser.parse(argc, argv); auto file = Core::File::construct(); - ; bool success; if (file_name == nullptr) { success = file->open(STDIN_FILENO, Core::IODevice::OpenMode::ReadOnly, Core::File::ShouldCloseFileDescription::No);