You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
println("Add a task named '${defualt_task}' to the .mog file to have it run when no task is provided to the mog command\n")
110
+
if mog_file !='' {
111
+
println("Add a task named '${defualt_task}' to the .mog file to have it run when no task is provided to the mog command\n")
112
+
}
78
113
print_version()
79
114
println('')
80
115
print_help(m)
@@ -86,7 +121,10 @@ fn main() {
86
121
eprint("No task named '${task_name}' found")
87
122
exit(1)
88
123
}
89
-
task.execute()
124
+
if mog_file_path !='.'&&'--no-cd'!in dash_args {
125
+
task.body.prepend('cd ${mog_file_path}')
126
+
}
127
+
task.execute(verbose)
90
128
}
91
129
92
130
fnprint_version() {
@@ -127,23 +165,39 @@ fn print_help(m ?Mog) {
127
165
println('Mog is a tool for running tasks from a .mog file in the current directory\n')
128
166
println('Usage:')
129
167
println(' mog [options] [task] [arguments]\n')
130
-
println('Any arguments passed after the task name will be forwarded to that task if you use the bash like {$#} syntax. For more info run "mog help arguments"\n')
131
168
print_options()
132
169
println('')
133
170
print_builtins_help()
134
171
println('')
135
-
print_commands(m)
172
+
print_list_help_topics()
173
+
println('')
174
+
ifdefinite_mog:= m {
175
+
if definite_mog.tasks.keys().len >0|| definite_mog.imports.keys().len >0 {
176
+
print_commands(m)
177
+
}
178
+
}
179
+
}
180
+
181
+
fnprint_list_help_topics() {
182
+
println('Help topics (run "mog help [topic]"):')
183
+
println(' arguments:\tShow information on using forwarded arguments from the cli')
184
+
println(' variables:\tShow built in variables')
136
185
}
137
186
138
187
fnprint_options() {
139
188
println('Options:')
189
+
println(' -v:\t\t\tShow the commands that will be executed')
190
+
println(' -p [path]:\t\tRun a .mog file from another location')
191
+
println('')
192
+
println(" --no-cd:\t\tDon't change cwd when running a mog file from another directory with '-p'")
193
+
println('')
140
194
println(' -l | --list:\t\tList available tasks')
141
195
println(' -h | --help:\t\tShow the help output')
142
196
println(' -V | --version:\tShow the version of mog')
143
197
}
144
198
145
199
fnprint_builtins_help() {
146
-
println("Built in task names that shouldn't be used in a .mog file:")
200
+
println("Built in tasks (these shouldn't be used in a .mog file):")
147
201
println(' help:\t\tShow the help output')
148
202
println(' symlink:\tCreate a symlink for the mog command to ~/.local/bin')
149
203
}
@@ -156,6 +210,24 @@ fn print_arguments_help() {
156
210
println('- {$"*"} becomes a single string, e.g., "arg1 arg2 arg3"')
157
211
println('- {$@} expands positional parameters as separate quoted strings')
158
212
println('- {$"@"} expands to "{$1}" "{$2}" "{$3}", treating each argument as a distinct entity')
213
+
println('\nExample:\n')
214
+
println('```')
215
+
println('run:')
216
+
println('\tpython my_script.py {$@} # this passes all cli arguments to the python script\n')
217
+
println('```\n')
218
+
println('In the cli:\n')
219
+
println('$ mog run arg1 arg2')
220
+
}
221
+
222
+
fnprint_builtin_vars_help() {
223
+
println('Built in variables:\n')
224
+
for key, value in mog.built_in_vars {
225
+
mutval:= value
226
+
if value.starts_with('\e') {
227
+
val='\\e${value[1..]}'
228
+
}
229
+
println('- ${key} = "${val}"')
230
+
}
159
231
}
160
232
161
233
fnljust(str string, len int, fill string) string {
0 commit comments