mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-06 11:09:05 +03:00
Userland: Port sleep(1) to Core::ArgsParser
This commit is contained in:
parent
27360f1f20
commit
62283ade91
Notes:
sideshowbarker
2024-07-19 06:07:23 +09:00
Author: https://github.com/bugaevc Commit: https://github.com/SerenityOS/serenity/commit/62283ade912 Pull-request: https://github.com/SerenityOS/serenity/pull/2394 Reviewed-by: https://github.com/awesomekling ✅
@ -24,7 +24,7 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -41,16 +41,12 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (argc != 2) {
|
||||
printf("usage: sleep <seconds>\n");
|
||||
return 1;
|
||||
}
|
||||
bool ok;
|
||||
unsigned secs = String(argv[1]).to_uint(ok);
|
||||
if (!ok) {
|
||||
fprintf(stderr, "Not a valid number of seconds: \"%s\"\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
int secs;
|
||||
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_positional_argument(secs, "Number of seconds to sleep for", "num-seconds");
|
||||
args_parser.parse(argc, argv);
|
||||
|
||||
struct sigaction sa;
|
||||
memset(&sa, 0, sizeof(struct sigaction));
|
||||
sa.sa_handler = handle_sigint;
|
||||
|
Loading…
Reference in New Issue
Block a user