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:
parent
987b5adf2a
commit
11599a3342
Notes:
sideshowbarker
2024-07-17 22:02:46 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/11599a33423 Pull-request: https://github.com/SerenityOS/serenity/pull/11467
1 changed files with 1 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue