12
12
epilog = "documentation: https://aspizu.github.io/goboscript-docs" ,
13
13
)
14
14
15
-
16
15
def input_t (argument : str ) -> Path :
17
16
path = Path (argument )
18
17
if not path .is_dir ():
@@ -23,14 +22,12 @@ def input_t(argument: str) -> Path:
23
22
)
24
23
return path
25
24
26
-
27
25
def output_t (argument : str ) -> Path :
28
26
path = Path (argument )
29
27
if path .is_dir ():
30
28
raise argparse .ArgumentTypeError (f"{ path } is a directory." )
31
29
return path
32
30
33
-
34
31
argparser .add_argument (
35
32
"--init" ,
36
33
action = "store_true" ,
@@ -56,23 +53,22 @@ def output_t(argument: str) -> Path:
56
53
watch = args .watch
57
54
if init_cmd :
58
55
path = Path ().absolute ()
56
+ file_data = [
57
+ (path / f"stage.{ EXT } " , 'costumes "blank.svg";\n ' ),
58
+ (path / f"main.{ EXT } " , 'costumes "blank.svg";\n \n onflag {\n say "Hello, World!";\n }\n ' ),
59
+ (path / "blank.svg" , '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"></svg><!--rotationCenter:0:0-->' ),
60
+ ]
59
61
if (path / f"stage.{ EXT } " ).is_file ():
60
62
argparser .error ("Working directory already contains a goboscript project." )
61
- (path / f"stage.{ EXT } " ).open ("w" ).write ('costumes "blank.svg";\n ' )
62
- (path / f"main.{ EXT } " ).open ("w" ).write (
63
- 'costumes "blank.svg";\n \n ' + "onflag {\n " ' say "Hello, World!";\n ' "}\n "
64
- )
65
- (path / "blank.svg" ).open ("w" ).write (
66
- '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"></svg><!--rotationCenter:0:0-->'
67
- )
63
+ ([file_path .open ("w" ).write (content ) for file_path , content in file_data ])
68
64
sys .exit ()
69
65
input : Path | None = args .input
70
66
if input is None :
71
67
input = Path ()
72
68
if not (input / f"stage.{ EXT } " ).is_file ():
73
69
argparser .error (
74
70
"Working directory is not a goboscript project, "
75
- "please provide an --input argument."
71
+ "Please provide proper directory using --input argument."
76
72
)
77
73
output : Path | None = args .output
78
74
if output is None :
@@ -81,8 +77,6 @@ def output_t(argument: str) -> Path:
81
77
argparser .error (
82
78
f"{ output } is a directory, please provide a different --output argument."
83
79
)
84
-
85
-
86
80
try :
87
81
build_gproject (input ).package (output )
88
82
except Error as e :
0 commit comments