aboutsummaryrefslogtreecommitdiff
path: root/src/args.py
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-10-01 11:49:53 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-10-01 11:49:53 +0200
commit1f18e740539aed751865ecff9d0f3cba44230e54 (patch)
treee23254751cc5a3be551233efb979a00571f40dc6 /src/args.py
parent763f02a8b1e69c0e26a088824981d23ba1e5386d (diff)
downloadphilosophers_test-1f18e740539aed751865ecff9d0f3cba44230e54.tar.gz
philosophers_test-1f18e740539aed751865ecff9d0f3cba44230e54.tar.bz2
philosophers_test-1f18e740539aed751865ecff9d0f3cba44230e54.zip
Refactoring file structure, Added summary
Diffstat (limited to 'src/args.py')
-rw-r--r--src/args.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/args.py b/src/args.py
new file mode 100644
index 0000000..899ef3f
--- /dev/null
+++ b/src/args.py
@@ -0,0 +1,50 @@
+# ############################################################################ #
+# #
+# ::: :::::::: #
+# args.py :+: :+: :+: #
+# +:+ +:+ +:+ #
+# By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ #
+# +#+#+#+#+#+ +#+ #
+# Created: 2020/10/01 10:23:09 by cacharle #+# #+# #
+# Updated: 2020/10/01 10:33:00 by cacharle ### ########.fr #
+# #
+# ############################################################################ #
+
+
+import argparse
+
+import config
+
+def parse_args():
+ parser = argparse.ArgumentParser(
+ description="Philosophers test",
+ formatter_class=argparse.RawTextHelpFormatter
+ )
+ parser.add_argument(
+ "-p", "--philo",
+ help="Id of the philosopher program to test \n"
+ "- 1: philo_one\n"
+ "- 2: philo_two\n"
+ "- 3: philo_three\n"
+ "- 0: all programs\n",
+ required=True,
+ type=int,
+ choices=[0, 1, 2, 3]
+ )
+ parser.add_argument(
+ "-b", "--build",
+ help="Build and exit",
+ action="store_true"
+ )
+ parser.add_argument(
+ "-g", "--pager",
+ help="Open {} in a pager after the test".format(config.RESULT_FILE),
+ action="store_true"
+ )
+ parser.add_argument(
+ "-t", "--timeout",
+ help="Change the philosopher process time (in seconds)",
+ type=float,
+ default=config.TIMEOUT
+ )
+ return parser.parse_args()