-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmkproject_work.ado
127 lines (114 loc) · 4.09 KB
/
mkproject_work.ado
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
*! version 2.1.3 22May2024 MLB
program define mkproject_work
version 15.1
syntax [anything], calling(string) [TEMPLate1(string) debug CREATE(string) query remove(string) default(string) RESETDEFault] *
if `"`calling'"' != "project" & `"`calling'"' != "boilerplate" {
di as err "{p}mkproject_work can only be called from mkproject or boilerplate{p_end}"
exit 198
}
if "`default'" != "" & "`resetdefault'" != "" {
di as err "{p}Cannot specify default() and resetdefault together{p_end}"
exit 198
}
if `"`create'`query'`default'`resetdefault'`anything'`remove'"' == "" {
di as err "{p}A name for your project is required{p_end}"
exit 198
}
if "`create'`query'`default'`resetdefault'`remove'" != "" & `"`anything'"' != "" {
di as err "{p}A name for a project cannot be specified together with the create(), remove(), query, default(), resetdefault options{p_end}"
exit 198
}
if "`create'`query'`default'`resetdefault'`remove'" != "" & "`type'" != "" {
di as err "{p}A type cannot be specified together with the create(), remove(), query, default(), resetdefault options{p_end}"
exit 198
}
if `"`remove'"' != "" & `"`create'`default'`resetdefault'"' != "" {
di as err "{p}cannot combine the the remove() option with either create(), default(), or resetdefault{p_end}"
exit 198
}
local proj mkproject__class_instance
if `"`create'"' != "" {
capture noisily Create `create', proj(`proj') calling("`calling'") `options'
Cleanup , proj(`proj') rc(`=_rc') `debug'
if "`query'`default'`resetdefault'" == "" exit
}
if `"`default'"' != "" {
capture noisily Default `default', proj(`proj') calling("`calling'")
Cleanup , proj(`proj') rc(`=_rc') `debug'
if "`query'`resetdefault'" == "" exit
}
if "`resetdefault'" != "" {
capture noisily Resetdefault, proj(`proj') calling("`calling'")
Cleanup , proj(`proj') rc(`=_rc') `debug'
if "`query'" == "" exit
}
if `"`remove'"' != "" {
capture noisily Remove, proj(`proj') calling("`calling'") remove(`"`remove'"')
Cleanup, proj(`proj') rc(`=_rc') `debug'
if "`query'" == "" exit
}
if "`query'" != "" {
capture noisily Query, proj(`proj') calling("`calling'")
Cleanup, proj(`proj') rc(`=_rc') `debug'
exit
}
capture noisily mkproject_main `anything', `options' proj(`proj') template(`template1') calling("`calling'")
Cleanup, proj(`proj') rc(`=_rc') `debug'
end
program define Create
syntax anything(name=create), proj(string) calling(string) [replace plus] *
mata: `proj' = mpcreate()
mata: `proj'.create("`calling'")
end
program define Query
syntax, proj(string) calling(string)
mata: `proj' = mpquery()
mata: `proj'.run("`calling'")
end
program define Default
syntax anything(name=default), proj(string) calling(string)
mata: `proj' = mpdefaults()
mata: `proj'.write_default("`calling'", "`default'")
end
program define Resetdefault
syntax, proj(string) calling(string)
mata: `proj' = mpdefaults()
mata: `proj'.reset("`calling'")
end
program define Remove
syntax, proj(string) calling(string) remove(string)
mata: `proj' = mpcreate()
mata: `proj'.remove("`remove'", "`calling'")
end
program define mkproject_main
version 10
syntax anything, proj(string) calling(string) ///
[ DIRectory(string) TEMPLate1(string)]
if "`calling'" == "project" {
mata: `proj' = mkproject()
mata: `proj'.run()
}
else if "`calling'" == "boilerplate" {
if `"`directory'"' != "" {
di as err "{p}option {bf:directory()} not allowed{p_end}"
exit 198
}
mata: `proj' = boilerplate()
mata: `proj'.parse_anything()
mata: `proj'.copy_boiler(`"`anything'"', "`template1'")
doedit `"`anything'"'
}
end
program define Cleanup
version 10
syntax, proj(string) rc(integer) [debug]
if `rc' {
mata:`proj'.graceful_exit()
}
if "`debug'" == "" {
mata: mata drop `proj'
}
if `rc' {
exit `rc'
}
end