diff options
author | Linus Groh <mail@linusgroh.de> | 2020-08-05 20:53:16 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-06 20:41:13 +0200 |
commit | 59942edcc04b429c8300811ff040e4fb5611d653 (patch) | |
tree | 612ff21f6d599a167d81896ac9fa96ab0285b39c | |
parent | 4565d2d415443e6d7bec65593600042d890cb6eb (diff) | |
download | serenity-59942edcc04b429c8300811ff040e4fb5611d653.zip |
Userland: Use Core::ArgsParser for 'pro'
-rw-r--r-- | Userland/pro.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/Userland/pro.cpp b/Userland/pro.cpp index fcad52f95a..18b8dd4141 100644 --- a/Userland/pro.cpp +++ b/Userland/pro.cpp @@ -27,6 +27,7 @@ #include <AK/NumberFormat.h> #include <AK/SharedBuffer.h> #include <AK/URL.h> +#include <LibCore/ArgsParser.h> #include <LibCore/EventLoop.h> #include <LibProtocol/Client.h> #include <LibProtocol/Download.h> @@ -34,15 +35,15 @@ int main(int argc, char** argv) { - if (argc != 2) { - printf("usage: %s <url>\n", argv[0]); - return 0; - } + const char* url_str = nullptr; + + Core::ArgsParser args_parser; + args_parser.add_positional_argument(url_str, "URL to download from", "url"); + args_parser.parse(argc, argv); - String url_string = argv[1]; - URL url(url_string); + URL url(url_str); if (!url.is_valid()) { - fprintf(stderr, "'%s' is not a valid URL\n", url_string.characters()); + fprintf(stderr, "'%s' is not a valid URL\n", url_str); return 1; } @@ -51,7 +52,7 @@ int main(int argc, char** argv) auto download = protocol_client->start_download(url.to_string()); if (!download) { - fprintf(stderr, "Failed to start download for '%s'\n", url_string.characters()); + fprintf(stderr, "Failed to start download for '%s'\n", url_str); return 1; } u32 previous_downloaded_size { 0 }; |