/* exported main */

const System = imports.system;

function lowerFirst(string) {
    return string[0].toLowerCase() + string.slice(1);
}

function main() {
    if (ARGV.length !== 1 || ARGV[0] == '--help' || ARGV[0] == '-h') {
        printerr('Supply a module name, such as Filter.Unread.');
        printerr('Pipe to `jq .` or `python -m json.tool` to pretty-print.');
        System.exit(1);
    }

    let module_name = ARGV[0];
    let module_path = module_name.split('.');
    let classname = module_path[module_path.length - 1];
    module_path = module_path.map(lowerFirst);
    let module = module_path.reduce((prev, curr) => prev[curr],
        imports.app.modules);
    print(JSON.stringify(module[classname].introspect()));
    System.exit(0);
}

@@ -14,16 +14,44 @@
 ain */%0A%0A
+const Gio = imports.gi.Gio;%0A
 const Sy
@@ -74,16 +74,103 @@
 ystem;%0A%0A
+function upperFirst(string) %7B%0A    return string%5B0%5D.toUpperCase() + string.slice(1);%0A%7D%0A%0A
 function
@@ -290,16 +290,41 @@
 gth 
-!==
+%3C
  1 %7C%7C
+ ARGV.length %3E 2 %7C%7C%0A       
  ARG
@@ -358,16 +358,71 @@
  == '-h'
+ %7C%7C%0A        (ARGV.length === 2 && ARGV%5B0%5D !== '--file')
 ) %7B%0A    
@@ -479,24 +479,83 @@
 .Unread.');%0A
+        printerr('Or supply a JS file name with --file.');%0A
         prin
@@ -663,84 +663,533 @@
 let 
-module_name = ARGV%5B0%5D;%0A    let module_path = module_name.split('.');%0A    let
+classname, module_path, importer;%0A    if (ARGV%5B0%5D === '--file') %7B%0A        let module_name = Gio.File.new_for_commandline_arg(ARGV%5B1%5D).get_path();%0A        if (module_name.endsWith('.js'))%0A            module_name = module_name.slice(0, -3);%0A        module_path = module_name.split('/');%0A        classname = upperFirst(module_path%5Bmodule_path.length - 1%5D);%0A        importer = imports%5B'.'%5D;%0A        importer.searchPath = %5B'/'%5D;%0A    %7D else %7B%0A        let module_name = ARGV%5B0%5D;%0A        module_path = module_name.split('.');%0A       
  cla
@@ -1234,16 +1234,20 @@
 h - 1%5D;%0A
+    
     modu
@@ -1285,16 +1285,63 @@
 First);%0A
+        importer = imports.app.modules;%0A    %7D%0A%0A
     let 
@@ -1399,36 +1399,17 @@
 rr%5D,
-%0A        imports.app.modules
+ importer
 );%0A 

Support absolute file paths