-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathmk.py
More file actions
39 lines (33 loc) · 739 Bytes
/
mk.py
File metadata and controls
39 lines (33 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import sys
import os
content = '''#include <catch2/catch.hpp>
#include <muda/muda.h>
#include <example_common.h>
using namespace muda;
void @NAME@()
{
example_desc("give a description to @NAME@");
}
TEST_CASE("@NAME@", "[@TAG@]")
{
@NAME@();
}
'''
tag = "default"
name = "example_name"
if(len(sys.argv) == 1):
print("usage: python mk.py [name:required] [tag:optional]")
exit(0)
if(len(sys.argv) > 1):
name = sys.argv[1]
if(len(sys.argv) > 2):
tag = sys.argv[2]
content = content.replace("@NAME@", name)
content = content.replace("@TAG@", tag)
filename = name + ".cu"
if not os.path.exists(filename):
f = open(filename, "w")
f.write(content)
f.close()
else:
print(f"{filename} already exists!")