summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/sleep.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/Userland/sleep.cpp b/Userland/sleep.cpp
index e4b40f05d7..76d7440e21 100644
--- a/Userland/sleep.cpp
+++ b/Userland/sleep.cpp
@@ -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;