diff --git a/Libraries/LibCore/CArgsParser.cpp b/Libraries/LibCore/CArgsParser.cpp index f4f65cca32..84caa72da3 100644 --- a/Libraries/LibCore/CArgsParser.cpp +++ b/Libraries/LibCore/CArgsParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2020, Sergey Bugaev * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,239 +27,295 @@ #include "CArgsParser.h" #include +#include #include -bool CArgsParserResult::is_present(const String& arg_name) const +CArgsParser::CArgsParser() { - return m_args.contains(arg_name); + add_option(m_show_help, "Display this message", "help", 0); } -String CArgsParserResult::get(const String& arg_name) const +void CArgsParser::parse(int argc, char** argv) { - return m_args.get(arg_name).value_or({}); -} + auto print_usage_and_exit = [this, argv] { + print_usage(stderr, argv[0]); + exit(1); + }; + Vector