summaryrefslogtreecommitdiff
path: root/backend/api/src/config.zig
diff options
context:
space:
mode:
Diffstat (limited to 'backend/api/src/config.zig')
-rw-r--r--backend/api/src/config.zig35
1 files changed, 35 insertions, 0 deletions
diff --git a/backend/api/src/config.zig b/backend/api/src/config.zig
new file mode 100644
index 0000000..fdc6cb7
--- /dev/null
+++ b/backend/api/src/config.zig
@@ -0,0 +1,35 @@
+const z = @import( "std" );
+
+pub var server_url: []const u8 = "http://localhost:8081";
+pub var server_port: u32 = 3000;
+pub var api_port: u32 = 3003;
+const memeql = z.mem.eql;
+
+pub fn parse() !void {
+ var args = z.process.args();
+ var argit = args.next();
+ while( argit ) |arg| : (argit = args.next()) {
+ if( memeql( u8, arg, "--domain" ) ) {
+ const next = args.next();
+ if( next ) |domain| {
+ server_url = domain;
+ }
+ }
+
+ if( memeql( u8, arg, "--port" ) ) {
+ const next = args.next();
+ if( next ) |port| {
+ const iport = z.fmt.parseInt( u32, port, 10 ) catch 3000;
+ server_port = iport;
+ }
+ }
+
+ if( memeql( u8, arg, "--api-port" ) ) {
+ const next = args.next();
+ if( next ) |port| {
+ const iport = z.fmt.parseInt( u32, port, 10 ) catch 3000;
+ api_port = iport;
+ }
+ }
+ }
+}