From 9ef6eb9b5f6190069ccde20c38232b98b48f55c7 Mon Sep 17 00:00:00 2001 From: Tristan Riehs Date: Sat, 1 Jun 2024 02:42:18 +0900 Subject: Add option for setting max and min --- src/calculer.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/calculer.c b/src/calculer.c index 0e442de..6b279ec 100644 --- a/src/calculer.c +++ b/src/calculer.c @@ -84,6 +84,10 @@ print_usage(FILE *stream) print_opt_noarg("V", "Print version and exit."); print_opt_noarg("h", "Print help and exit."); print_opt_arg("l", "LOGFILE", "Use LOGFILE as log file.\n"); + print_opt_arg("m", "MIN", + "Set MIN as the minimum value numbers can take.\n"); + print_opt_arg("M", "MAX", + "Set MAX as the maximum value numbers can take.\n"); } void @@ -113,7 +117,7 @@ main(int argc, char *argv[]) assert(bytes_written); int opt; - while ((opt = getopt(argc, argv, ":Vhl:")) != -1) + while ((opt = getopt(argc, argv, ":Vhl:m:M:")) != -1) { switch (opt) { @@ -126,6 +130,12 @@ main(int argc, char *argv[]) case 'l': logpath = optarg; break; + case 'm': + lower = atoi(optarg); + break; + case 'M': + upper = atoi(optarg); + break; case ':': fprintf(stderr, "calculer: option %d requires an argument\n", -- cgit v1.2.3