src/jsdoc/PackerRun.vala
[roojspacker] / src / jsdoc / PackerRun.vala
index 70c5496..25b6209 100644 (file)
@@ -20,9 +20,9 @@ namespace JSDOC
        // --------------- <<<<<<< <MAIN HERE....
        
 #if HAVE_OLD_GLIB
-       class PackerRun : Object 
+       public class PackerRun : Object 
 #else
-       class PackerRun : Application   
+       public class PackerRun : Application    
 #endif
        {
                public  string opt_target = null;
@@ -81,8 +81,7 @@ namespace JSDOC
                public  string opt_doc_ext = "html";
                
        
-               public   OptionEntry[] options;
-       
                public PackerRun ()
                {
 #if !HAVE_OLD_GLIB             
@@ -91,7 +90,11 @@ namespace JSDOC
                                flags: ApplicationFlags.HANDLES_COMMAND_LINE 
                        );
 #endif         
-                       this.options     = {
+
+               }
+               void parseArgs(string[] args)
+               {
+                       GLib.OptionEntry[] options       = {
                                OptionEntry() {
                                        long_name = "jsfile",
                                        short_name = 'f',
@@ -160,12 +163,36 @@ namespace JSDOC
                                        description = "Skip scope parsing and variable replacement",
                                        arg_description = null
                                }, 
+                               OptionEntry() {
+                                       long_name = "debug",
+                                       short_name = 'D',
+                                       flags = 0,
+                                       arg =  OptionArg.NONE,
+                                       arg_data = &opt_debug,
+                                       description = "Show debug messages",
+                                       arg_description = null
+                               }, 
+
+                               OptionEntry() {
+                                       long_name = "dump-tokens",
+                                       short_name = 'k',
+                                       flags = 0,
+                                       arg =  OptionArg.NONE,
+                                       arg_data = &opt_dump_tokens,
+                                       description = "Dump the tokens from a file",
+                                       arg_description = null
+                               }, 
+
+                               OptionEntry() {
+                                       long_name = "clean-cache",
+                                       short_name = 'c',
+                                       flags = 0,
+                                       arg =  OptionArg.NONE,
+                                       arg_data = &opt_clean_cache,
+                                       description = "Clean up the cache after running (slower)",
+                                       arg_description = null
+                               }, 
 
-                       { "keep-whitespace", 'w', 0, OptionArg.NONE, ref opt_keep_whitespace, "Keep whitespace", null },
-                       { "skip-scope", 's', 0, OptionArg.NONE, ref opt_skip_scope, "Skip scope parsing and variable replacement", null },
-                       { "debug", 0, 0, OptionArg.NONE, ref opt_debug, "Show debug messages", null },
-                       { "dump-tokens", 'k', 0, OptionArg.NONE, ref opt_dump_tokens, "Dump the tokens from a file", null },
-                       { "clean-cache", 'c', 0, OptionArg.NONE, ref opt_clean_cache, "Clean up the cache after running (slower)", null },
 
                        // fixme -- keepwhite.. cleanup 
                        
@@ -175,21 +202,64 @@ namespace JSDOC
                        //       --index-files roojs1/buildSDK/dependancy_core.txt  \
                        //       --index-files roojs1/buildSDK/dependancy_ui.txt  \
                        //       --index-files roojs1/buildSDK/dependancy_bootstrap.txt  \
-                       //       --doc-template-dir\
-                       
-                       
-                       { "doc-target", 'd', 0, OptionArg.STRING, ref opt_doc_target, "Documentation Directory target", null },
-                       { "doc-template-dir", 'p', 0, OptionArg.STRING, ref opt_doc_template_dir, "Documentation Directory target", null },
-                       { "doc-private", 'p', 0, OptionArg.NONE, ref opt_doc_include_private, "Document Private functions", null },                                             
-                       
+                       //       --doc-template-dir \
                        
+                               OptionEntry() {
+                                       long_name = "doc-target",
+                                       short_name = 'd',
+                                       flags = 0,
+                                       arg =  OptionArg.STRING,
+                                       arg_data = &opt_doc_target,
+                                       description = "Clean up the cache after running (slower)",
+                                       arg_description = null
+                               }, 
+
+                               OptionEntry() {
+                                       long_name = "doc-template-dir",
+                                       short_name = 'p',
+                                       flags = 0,
+                                       arg =  OptionArg.STRING,
+                                       arg_data = &opt_doc_template_dir,
+                                       description = "Documentation Directory target",
+                                       arg_description = null
+                               },                      
+
+
+                               OptionEntry() {
+                                       long_name = "doc-private",
+                                       short_name = 'P',
+                                       flags = 0,
+                                       arg =  OptionArg.NONE,
+                                       arg_data = &opt_doc_include_private,
+                                       description = "Document Private functions",
+                                       arg_description = null
+                               }
+                       };
+                       var opt_context = new OptionContext ("JSDOC Packer");
+
+                       try {
+                               opt_context.set_help_enabled (true);
+                               opt_context.add_main_entries (options, null);
+                               if (!opt_context.parse ( ref args)) {
+                                       print("options parse error");
+                                       GLib.Process.exit(Posix.EXIT_FAILURE);
+                               }
+
+
+                                
+
+                       } catch (OptionError e) {
+                               stdout.printf ("error: %s\n", e.message);
+                               stdout.printf ("Run '%s --help' to see a full list of available command line options.\n %s", 
+                                                        args[0], opt_context.get_help(true,null));
+                               GLib.Process.exit(Posix.EXIT_FAILURE);
+                                
+                       }
                        
-                       { null }
-               };
                                         
                         
                }
-               public void  run()
+               public void  runPack()
                {       
                        // what's required...
                        if (opt_debug) {