Commit 4480b63 1 parent b47ea60 commit 4480b63 Copy full SHA for 4480b63
File tree 1 file changed +34
-2
lines changed
1 file changed +34
-2
lines changed Original file line number Diff line number Diff line change 30
30
def main (argv : Sequence [str ]):
31
31
if len (argv ) < 2 :
32
32
print (
33
- """\u001b [31mERROR: missing command-line argument to Mesop application .\u001b [0m
33
+ """\u001b [31mERROR: missing command-line argument to Mesop.\u001b [0m
34
34
35
- Example command:
35
+ Example run command:
36
36
$\u001b [35m mesop file.py\u001b [0m"""
37
37
)
38
38
sys .exit (1 )
39
39
40
+ if argv [1 ] == "init" :
41
+ if len (argv ) > 3 :
42
+ print (
43
+ f"""\u001b [31mERROR: Too many command-line arguments for mesop init.\u001b [0m
44
+
45
+ Actual:
46
+ $\u001b [35m mesop { " " .join (argv [1 :])} \u001b [0m
47
+
48
+ Re-run with:
49
+ $\u001b [35m mesop init file.py\u001b [0m"""
50
+ )
51
+ sys .exit (1 )
52
+
53
+ filename = argv [2 ] if len (argv ) == 3 else "main.py"
54
+ absolute_path = make_path_absolute (filename )
55
+ if os .path .isfile (absolute_path ):
56
+ print (f"\u001b [31mERROR: { filename } already exists.\u001b [0m" )
57
+ sys .exit (1 )
58
+ with open (
59
+ os .path .join (
60
+ os .path .dirname (os .path .abspath (__file__ )),
61
+ "../examples/starter_kit/starter_kit.py" ,
62
+ )
63
+ ) as src_file :
64
+ with open (absolute_path , "w" ) as dest_file :
65
+ dest_file .write (src_file .read ().replace ("/starter_kit" , "/" ))
66
+ print (f"""Created starter kit Mesop app at { filename } 🎉
67
+
68
+ Run Mesop app:
69
+ $\u001b [35m mesop { filename } \u001b [0m
70
+ """ )
71
+ sys .exit (0 )
40
72
if len (argv ) > 2 :
41
73
print (
42
74
f"""\u001b [31mERROR: Too many command-line arguments.\u001b [0m
You can’t perform that action at this time.
0 commit comments