tbegin handling arguments in main program - granular - granular dynamics simula… | |
git clone git://src.adamsgaard.dk/granular | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit a073560547b40f27f19e26cd637b882a77d098aa | |
parent 9f9ae51babeb3000e46c54c26b26cf88dc7e8d8f | |
Author: Anders Damsgaard <[email protected]> | |
Date: Thu, 25 Mar 2021 22:17:20 +0100 | |
begin handling arguments in main program | |
Diffstat: | |
M granular.c | 20 ++++++++++++++++++++ | |
M granularpacking.c | 1 - | |
2 files changed, 20 insertions(+), 1 deletion(-) | |
--- | |
diff --git a/granular.c b/granular.c | |
t@@ -1,5 +1,16 @@ | |
#include <stdlib.h> | |
+#include <err.h> | |
#include "simulation.h" | |
+#include "arg.h" | |
+ | |
+char *argv0; | |
+ | |
+static void | |
+usage(void) | |
+{ | |
+ errx(1, "usage: %s " | |
+ "[-h]", argv0); | |
+} | |
int | |
main(int argc, char *argv[]) | |
t@@ -12,6 +23,15 @@ main(int argc, char *argv[]) | |
#endif | |
sim_defaults(&sim); | |
+ | |
+ ARGBEGIN { | |
+ case 'h': | |
+ usage(); | |
+ break; | |
+ default: | |
+ usage(); | |
+ } ARGEND; | |
+ | |
sim_read_grains(&sim, stdin); | |
if (sim.t < sim.t_end) | |
sim_run_time_loop(&sim); | |
diff --git a/granularpacking.c b/granularpacking.c | |
t@@ -5,7 +5,6 @@ | |
#include "simulation.h" | |
#include "arrays.h" | |
#include "util.h" | |
- | |
#include "arg.h" | |
char *argv0; |