pls: Stop on first non option when parsing arguments

This allows using pls on a program with arguments more ergonomically,
e.g. `pls -- echo "hello friends"` can now simply be done as:
`pls echo "hello friends"`.
This commit is contained in:
Idan Horowitz 2021-12-28 20:10:22 +02:00
parent 987b5adf2a
commit 11599a3342
Notes: sideshowbarker 2024-07-17 22:02:46 +09:00

View file

@ -18,6 +18,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Vector<char const*> command;
Core::ArgsParser args_parser;
uid_t as_user_uid = 0;
args_parser.set_stop_on_first_non_option(true);
args_parser.add_option(as_user_uid, "User to execute as", nullptr, 'u', "UID");
args_parser.add_positional_argument(command, "Command to run at elevated privilege level", "command");
args_parser.parse(arguments);