lib/markdown: nitmd use `config` instead of `options`
authorAlexandre Terrasa <alexandre@moz-code.org>
Tue, 8 May 2018 22:19:25 +0000 (18:19 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Fri, 11 May 2018 14:58:43 +0000 (10:58 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

lib/markdown/nitmd.nit

index 83e457d..34e8d93 100644 (file)
@@ -19,22 +19,25 @@ import markdown
 import decorators
 import man
 
-import opts
+import config
 
-var options = new OptionContext
-var opt_help = new OptionBool("Show this help.", "-h", "-?", "--help")
-options.add_option(opt_help)
 var opt_to = new OptionString("Specify output format (html, md, man)", "-t", "--to")
-options.add_option(opt_to)
 
-options.parse(args)
-if options.rest.length != 1 then
-       print "usage: nitmd [-t format] <file.md>"
-       options.usage
+var usage = new Buffer
+usage.append "Usage: nitmd [-t format] <file.md>\n"
+usage.append "Translate Markdown documents to other formats."
+
+var config = new Config
+config.add_option(opt_to)
+config.tool_description = usage.write_to_string
+
+config.parse_options(args)
+if config.args.length != 1 then
+       config.usage
        exit 1
 end
 
-var file = options.rest.first
+var file = config.args.first
 if not file.file_exists then
        print "'{file}' not found"
        exit 1