mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:07:45 +00:00
Userland: Use Core::ArgsParser for 'md'
This commit is contained in:
parent
f6369a66b1
commit
ab1f3551cc
1 changed files with 5 additions and 6 deletions
|
@ -27,6 +27,7 @@
|
||||||
#include <AK/ByteBuffer.h>
|
#include <AK/ByteBuffer.h>
|
||||||
#include <AK/OwnPtr.h>
|
#include <AK/OwnPtr.h>
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <LibCore/File.h>
|
#include <LibCore/File.h>
|
||||||
#include <LibMarkdown/Document.h>
|
#include <LibMarkdown/Document.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -42,14 +43,12 @@ int main(int argc, char* argv[])
|
||||||
const char* file_name = nullptr;
|
const char* file_name = nullptr;
|
||||||
bool html = false;
|
bool html = false;
|
||||||
|
|
||||||
for (int i = 1; i < argc; i++)
|
Core::ArgsParser args_parser;
|
||||||
if (strcmp(argv[i], "--html") == 0)
|
args_parser.add_option(html, "Render to HTML rather than for the terminal", "html", 'H');
|
||||||
html = true;
|
args_parser.add_positional_argument(file_name, "Path to Markdown file", "path", Core::ArgsParser::Required::No);
|
||||||
else
|
args_parser.parse(argc, argv);
|
||||||
file_name = argv[i];
|
|
||||||
|
|
||||||
auto file = Core::File::construct();
|
auto file = Core::File::construct();
|
||||||
;
|
|
||||||
bool success;
|
bool success;
|
||||||
if (file_name == nullptr) {
|
if (file_name == nullptr) {
|
||||||
success = file->open(STDIN_FILENO, Core::IODevice::OpenMode::ReadOnly, Core::File::ShouldCloseFileDescription::No);
|
success = file->open(STDIN_FILENO, Core::IODevice::OpenMode::ReadOnly, Core::File::ShouldCloseFileDescription::No);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue