1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 07:27:45 +00:00

LibCore: Move AK/ArgsParser to LibCore/CArgsParser

Also rename the classes to match LibCore naming style.
This means that it's no longer incorrectly linked into LibC and Kernel.
This commit is contained in:
Robin Burchell 2019-05-17 15:35:30 +02:00 committed by Andreas Kling
parent 190111e21a
commit 77dfd419e9
10 changed files with 49 additions and 56 deletions

View file

@ -2,17 +2,17 @@
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <AK/ArgsParser.h>
#include <LibCore/CArgsParser.h>
int main(int argc, char** argv)
{
AK::ArgsParser args_parser("ln");
CArgsParser args_parser("ln");
args_parser.add_arg("s", "create a symlink");
args_parser.add_required_single_value("target");
args_parser.add_required_single_value("link-path");
AK::ArgsParserResult args = args_parser.parse(argc, (const char**)argv);
CArgsParserResult args = args_parser.parse(argc, (const char**)argv);
Vector<String> values = args.get_single_values();
if (values.size() == 0) {
args_parser.print_usage();

View file

@ -6,10 +6,10 @@
#include <fcntl.h>
#include <dirent.h>
#include <AK/AKString.h>
#include <AK/ArgsParser.h>
#include <AK/StringBuilder.h>
#include <AK/Vector.h>
#include <AK/FileSystemPath.h>
#include <LibCore/CArgsParser.h>
#include <LibGUI/GDesktop.h>
#include <LibGUI/GApplication.h>
@ -52,13 +52,13 @@ int main(int argc, char** argv)
{
GApplication app(argc, argv);
AK::ArgsParser args_parser("pape");
CArgsParser args_parser("pape");
args_parser.add_arg("a", "show all wallpapers");
args_parser.add_arg("c", "show current wallpaper");
args_parser.add_single_value("name");
AK::ArgsParserResult args = args_parser.parse(argc, (const char**)argv);
CArgsParserResult args = args_parser.parse(argc, (const char**)argv);
if (args.is_present("a"))
return handle_show_all();

View file

@ -3,9 +3,9 @@
#include <signal.h>
#include <stdlib.h>
#include <LibCore/CProcessStatisticsReader.h>
#include <LibCore/CArgsParser.h>
#include <AK/AKString.h>
#include <AK/Vector.h>
#include <AK/ArgsParser.h>
#include <AK/HashMap.h>
static int pid_of(const String& process_name, bool single_shot, bool omit_pid, pid_t pid)
@ -34,12 +34,12 @@ static int pid_of(const String& process_name, bool single_shot, bool omit_pid, p
int main(int argc, char** argv)
{
AK::ArgsParser args_parser("pidof");
CArgsParser args_parser("pidof");
args_parser.add_arg("s", "Single shot - this instructs the program to only return one pid");
args_parser.add_arg("o", "pid", "Tells pidof to omit processes with that pid. The special pid %PPID can be used to name the parent process of the pidof program.");
AK::ArgsParserResult args = args_parser.parse(argc, (const char**)argv);
CArgsParserResult args = args_parser.parse(argc, (const char**)argv);
bool s_arg = args.is_present("s");
bool o_arg = args.is_present("o");

View file

@ -4,10 +4,10 @@
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <AK/ArgsParser.h>
#include <AK/AKString.h>
#include <AK/StringBuilder.h>
#include <AK/Vector.h>
#include <LibCore/CArgsParser.h>
static String read_var(const String& name)
{
@ -104,12 +104,12 @@ static int handle_var(const String& var)
int main(int argc, char** argv)
{
AK::ArgsParser args_parser("sysctl");
CArgsParser args_parser("sysctl");
args_parser.add_arg("a", "show all variables");
args_parser.add_single_value("variable=[value]");
AK::ArgsParserResult args = args_parser.parse(argc, (const char**)argv);
CArgsParserResult args = args_parser.parse(argc, (const char**)argv);
if (args.is_present("a")) {
return handle_show_all();

View file

@ -4,8 +4,8 @@
#include <errno.h>
#include <unistd.h>
#include <AK/Assertions.h>
#include <AK/ArgsParser.h>
#include <LibCore/CFile.h>
#include <LibCore/CArgsParser.h>
int tail_from_pos(CFile& file, off_t startline, bool want_follow)
{
@ -75,13 +75,13 @@ static void exit_because_we_wanted_lines()
int main(int argc, char *argv[])
{
AK::ArgsParser args_parser("tail");
CArgsParser args_parser("tail");
args_parser.add_arg("f", "follow -- appended data is output as it is written to the file");
args_parser.add_arg("n", "lines", "fetch the specified number of lines");
args_parser.add_required_single_value("file");
AK::ArgsParserResult args = args_parser.parse(argc, (const char**)argv);
CArgsParserResult args = args_parser.parse(argc, (const char**)argv);
Vector<String> values = args.get_single_values();
if (values.size() != 1) {