diff options
author | Linus Groh <mail@linusgroh.de> | 2020-08-05 21:09:35 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-06 20:41:13 +0200 |
commit | ab1f3551cca414cefc3c4e14bbe0cd2fc21fff97 (patch) | |
tree | dfb5efb42b80ccdf0523fed42d1bd7751078f4b0 | |
parent | f6369a66b19b72bd7bfd8cb532c0669817d6b6e8 (diff) | |
download | serenity-ab1f3551cca414cefc3c4e14bbe0cd2fc21fff97.zip |
Userland: Use Core::ArgsParser for 'md'
-rw-r--r-- | Userland/md.cpp | 11 |
1 files 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 <AK/ByteBuffer.h> #include <AK/OwnPtr.h> #include <AK/String.h> +#include <LibCore/ArgsParser.h> #include <LibCore/File.h> #include <LibMarkdown/Document.h> #include <stdio.h> @@ -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); |