aboutsummaryrefslogtreecommitdiff
path: root/src/args.js
diff options
context:
space:
mode:
authorLizzy Hunt <lizzy.hunt@usu.edu>2024-02-23 11:48:48 -0700
committerLizzy Hunt <lizzy.hunt@usu.edu>2024-02-23 11:48:48 -0700
commit76bca61a5ca50a5033486b51d7b7829ec831fd98 (patch)
tree443a9def75bc5bf37e89fc1bbe7bb3a9795b484a /src/args.js
parent7331da69aa3442d7edaed4160b5a6bd3239ed265 (diff)
downloadaggietimed-main.tar.gz
aggietimed-main.zip
update with new api logicHEADmain
Diffstat (limited to 'src/args.js')
-rw-r--r--src/args.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/args.js b/src/args.js
new file mode 100644
index 0000000..6f06e0b
--- /dev/null
+++ b/src/args.js
@@ -0,0 +1,44 @@
+import { DEFAULT_SOCKET_PATH, DEFAULT_PASS_CMD } from "./constants.js";
+import { ACTIONS } from "./actions.js";
+import * as argparse from "argparse";
+
+export const build_args = () => {
+ const parser = new argparse.ArgumentParser({ description: "AggieTime CLI" });
+
+ parser.add_argument("-cos", "--cookie-on-stdin", {
+ help: "set AggieTime cookie from stdin",
+ action: argparse.BooleanOptionalAction,
+ default: false,
+ });
+
+ parser.add_argument("-d", "--daemon", {
+ help: "start server as a process blocking daemon",
+ action: argparse.BooleanOptionalAction,
+ default: false,
+ });
+
+ parser.add_argument("-pos", "--position-id", {
+ help: "your AggieTime Position ID (for usage with --action clock_in or clock_out). (default: first returned by AggieTime)",
+ default: undefined,
+ });
+
+ parser.add_argument("-s", "--socket_path", {
+ default: DEFAULT_SOCKET_PATH,
+ help: `set server socket path (default: ${DEFAULT_SOCKET_PATH})`,
+ });
+
+ parser.add_argument("-p", "--pass_cmd", {
+ default: DEFAULT_PASS_CMD,
+ help: `set anumber/password collection retrieval command (default: "${DEFAULT_PASS_CMD}")`,
+ });
+
+ parser.add_argument("-a", "--action", {
+ help: `ignored when daemon flag is set. possible actions are: ${Array.from(
+ Object.keys(ACTIONS),
+ )
+ .map((x) => `"${x}"`)
+ .join(", ")}.`,
+ });
+
+ return parser.parse_args();
+};