mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
d43a7eae54
As usual, this removes many unused includes and moves used includes further down the chain.
38 lines
1.1 KiB
C++
38 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) 2020, Sergey Bugaev <bugaevc@serenityos.org>
|
|
* Copyright (c) 2020, Linus Groh <linusg@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <AK/URL.h>
|
|
#include <AK/Vector.h>
|
|
#include <LibCore/ArgsParser.h>
|
|
#include <LibCore/DeprecatedFile.h>
|
|
#include <LibCore/EventLoop.h>
|
|
#include <LibDesktop/Launcher.h>
|
|
#include <LibMain/Main.h>
|
|
|
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|
{
|
|
Core::EventLoop loop;
|
|
Vector<StringView> urls_or_paths;
|
|
Core::ArgsParser parser;
|
|
parser.set_general_help("Open a file or URL by executing the appropriate program.");
|
|
parser.add_positional_argument(urls_or_paths, "URL or file path to open", "url-or-path");
|
|
parser.parse(arguments);
|
|
|
|
bool all_ok = true;
|
|
|
|
for (auto& url_or_path : urls_or_paths) {
|
|
auto path = Core::DeprecatedFile::real_path_for(url_or_path);
|
|
auto url = URL::create_with_url_or_path(path.is_null() ? url_or_path : path.view());
|
|
|
|
if (!Desktop::Launcher::open(url)) {
|
|
warnln("Failed to open '{}'", url);
|
|
all_ok = false;
|
|
}
|
|
}
|
|
|
|
return all_ok ? 0 : 1;
|
|
}
|