diff options
author | Nicholas Noll <nbnoll@eml.cc> | 2020-05-15 18:11:58 -0700 |
---|---|---|
committer | Nicholas Noll <nbnoll@eml.cc> | 2020-05-15 18:11:58 -0700 |
commit | fa25c8f3df6791727b9384c9b405c996ac68b8ab (patch) | |
tree | a7a2a627b0deb612472138f389fe533761a01f0e /bin/initmk | |
parent | 05aeef535ac60ccca81fe58bc6a0152ca80bc211 (diff) |
feat: added buffered io to libn
Diffstat (limited to 'bin/initmk')
-rwxr-xr-x | bin/initmk | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -1,5 +1,6 @@ #!/bin/python +import os import sys NAME = "rules.mk" @@ -10,7 +11,7 @@ TEMPLATE = """include share/push.mk SRCS_$(d) := $(wildcard $(d)/*.c) LIBS_$(d) := BINS_$(d) := -TSTS_$(d) := +TSTS_$(d) := $(wildcard $(d)/*_test.c:.c=.test) include share/pop.mk @@ -28,8 +29,17 @@ $(BINS_$(d)): $(OBJS_$(d)) include share/pop.mk""" if __name__ == "__main__": + if len(sys.argv) == 2: + dir = sys.argv[1] + if not os.path.exists(dir): + raise ValueError(f"path '{dir}' does not exist") + path = f"{dir}/{NAME}" + elif len(sys.argv) > 2: + raise ValueError("only one argument is accepted") + else: + path = NAME try: - with open(NAME, 'x') as makefile: + with open(path, 'x') as makefile: makefile.write(f"{TEMPLATE}\n") except: print("rules.mk already present", file=sys.stderr) |