copy: Port to LibMain :^)

This commit is contained in:
Kenneth Myhra 2021-11-25 20:58:56 +01:00 committed by Andreas Kling
parent 507de4bc1d
commit 430e231f5e
Notes: sideshowbarker 2024-07-18 00:40:16 +09:00
2 changed files with 8 additions and 6 deletions

View file

@ -62,7 +62,7 @@ target_link_libraries(checksum LibCrypto)
target_link_libraries(chres LibGUI)
target_link_libraries(cksum LibCrypto)
target_link_libraries(config LibConfig)
target_link_libraries(copy LibGUI)
target_link_libraries(copy LibGUI LibMain)
target_link_libraries(diff LibDiff)
target_link_libraries(disasm LibX86)
target_link_libraries(dmesg LibMain)

View file

@ -10,8 +10,10 @@
#include <AK/StringBuilder.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/File.h>
#include <LibCore/System.h>
#include <LibGUI/Application.h>
#include <LibGUI/Clipboard.h>
#include <LibMain/Main.h>
#include <unistd.h>
struct Options {
@ -20,7 +22,7 @@ struct Options {
bool clear;
};
static Options parse_options(int argc, char* argv[])
static Options parse_options(Main::Arguments arguments)
{
const char* type = "text/plain";
Vector<const char*> text;
@ -31,7 +33,7 @@ static Options parse_options(int argc, char* argv[])
args_parser.add_option(type, "Pick a type", "type", 't', "type");
args_parser.add_option(clear, "Instead of copying, clear the clipboard", "clear", 'c');
args_parser.add_positional_argument(text, "Text to copy", "text", Core::ArgsParser::Required::No);
args_parser.parse(argc, argv);
args_parser.parse(arguments);
Options options;
options.type = type;
@ -60,11 +62,11 @@ static Options parse_options(int argc, char* argv[])
return options;
}
int main(int argc, char* argv[])
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
auto app = GUI::Application::construct(argc, argv);
auto app = GUI::Application::construct(arguments);
Options options = parse_options(argc, argv);
Options options = parse_options(arguments);
auto& clipboard = GUI::Clipboard::the();
if (options.clear)