@@ -116,7 +116,7 @@ def check_remote_status(args, strict=False):
116
116
sys .stderr .write ('warning: {}\n ' .format (msg ))
117
117
118
118
119
- def deploy (args ):
119
+ def deploy (parser , args ):
120
120
cfg = load_mkdocs_config (args , strict = True )
121
121
check_remote_status (args , strict = True )
122
122
with commands .deploy (cfg , args .version , args .title , args .alias ,
@@ -129,7 +129,7 @@ def deploy(args):
129
129
git_utils .push_branch (args .remote , args .branch , args .force )
130
130
131
131
132
- def delete (args ):
132
+ def delete (parser , args ):
133
133
load_mkdocs_config (args )
134
134
check_remote_status (args , strict = True )
135
135
commands .delete (args .version , args .all , branch = args .branch ,
@@ -138,7 +138,7 @@ def delete(args):
138
138
git_utils .push_branch (args .remote , args .branch , args .force )
139
139
140
140
141
- def alias (args ):
141
+ def alias (parser , args ):
142
142
cfg = load_mkdocs_config (args )
143
143
check_remote_status (args , strict = True )
144
144
commands .alias (cfg , args .version , args .alias , args .update_aliases ,
@@ -148,7 +148,7 @@ def alias(args):
148
148
git_utils .push_branch (args .remote , args .branch , args .force )
149
149
150
150
151
- def retitle (args ):
151
+ def retitle (parser , args ):
152
152
load_mkdocs_config (args )
153
153
check_remote_status (args , strict = True )
154
154
commands .retitle (args .version , args .title , branch = args .branch ,
@@ -157,7 +157,7 @@ def retitle(args):
157
157
git_utils .push_branch (args .remote , args .branch , args .force )
158
158
159
159
160
- def list_versions (args ):
160
+ def list_versions (parser , args ):
161
161
def print_version (info ):
162
162
version = str (info .version )
163
163
aliases = (' [{}]' .format (', ' .join (sorted (info .aliases )))
@@ -192,7 +192,7 @@ def print_version(info):
192
192
print_version (i )
193
193
194
194
195
- def set_default (args ):
195
+ def set_default (parser , args ):
196
196
load_mkdocs_config (args )
197
197
check_remote_status (args , strict = True )
198
198
commands .set_default (args .version , args .template , branch = args .branch ,
@@ -201,12 +201,16 @@ def set_default(args):
201
201
git_utils .push_branch (args .remote , args .branch , args .force )
202
202
203
203
204
- def serve (args ):
204
+ def serve (parser , args ):
205
205
load_mkdocs_config (args )
206
206
check_remote_status (args )
207
207
commands .serve (args .dev_addr , branch = args .branch )
208
208
209
209
210
+ def help (parser , args ):
211
+ parser .parse_args (args .subcommand + ['--help' ])
212
+
213
+
210
214
def main ():
211
215
parser = argparse .ArgumentParser (prog = 'mike' , description = description )
212
216
subparsers = parser .add_subparsers (metavar = 'COMMAND' )
@@ -304,8 +308,15 @@ def main():
304
308
help = ('IP address and port to serve from ' +
305
309
'(default: %(default)s)' ))
306
310
311
+ help_p = subparsers .add_parser (
312
+ 'help' , help = 'show this help message and exit' , add_help = False
313
+ )
314
+ help_p .set_defaults (func = help )
315
+ help_p .add_argument ('subcommand' , metavar = 'CMD' , nargs = argparse .REMAINDER ,
316
+ help = 'subcommand to request help for' )
317
+
307
318
args = parser .parse_args ()
308
319
try :
309
- return args .func (args )
320
+ return args .func (parser , args )
310
321
except Exception as e :
311
322
parser .exit (1 , 'error: {}\n ' .format (str (e )))
0 commit comments