photo
Jordan Sissel
geek

Thu, 14 Jun 2007

xulrunner command line adventures

Oh my god. If you followed the link, you surely noticd the 170ish lines in the example that shows you how to make use of command-line arguments from JavaScript. I totally forgot how nasty it is to often to simple things in XUL/XPCOM-land.

In my adventures of searching for telling teaching a small xulrunner application I'm working on to use the commandline, I found Crowbar, a project out of MIT that's pretty neat.

Basically I wanted the power of my xpathtool but twist it with some help from jQuery. A command-line jquery tool would let you do some pretty neat things with web scraping. Crowbar can already do the page fetching, but I want to do more. And no, by 'command-line jquery tool' I certainly do not mean this command line jquery documentation tool.

My frustration with XPCOM's burden-the-programmer design has me at the end of my patience for tonight. Basically I suck at XPCOM in JavaScript. I'll keep at it though, maybe something useful will come out. come out of it.

Update: Neat! While surfing through Crowbar's code for how they handle commandline arguments, I found this beauty:

/*
 * Process a series of command line arguments and modify default settings
 */
function processCommandLineArgs() {
  var nsCommandLine = window.arguments[0];
  nsCommandLine = nsCommandLine.QueryInterface(Components.interfaces.nsICommandLine);
  port = getCommandLineArg(nsCommandLine, 'port', port);
}
So, I try this out myself:
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        onload="alert(window.arguments[0].QueryInterface(Components.interfaces.nsICommandLine).getArgument(0))" />
And run xulrunner:
% xulrunner application.ini happypants
The result is this:

Comments: 0 (view comments)
Tags: ,
Permalink: /geekery/xulrunner-commandline-adventures
posted at: 04:19


0 responses to 'xulrunner command line adventures'


Leave a reply

You need javascript enabled to use this form. Anti-spam efforts ongoing. Also, if the comment doesn't show up, it's because the form expired. Go back and copy your comment, reload the form, and resubmit. Apologies if this is a hassle, I'm just playing with antispam methods right now. If this insists on not working, please email me about it.

Name (required)
E-mail (optional, if you want me to be able to email you back)
URL (also optional)
Comment:


Search this site

Navigation

Metadata

Home About Resume My Code (SVN)

Articles

ARP Security Dynamic DNS with DHCP OpenLDAP+Kerberos+SASL PPP over SSH SSH Security: /bin/false Week of Unix Tools Work Efficiency

Projects

fex firefox tabsearch firefox urledit grok keynav liboverride newpsm (FreeBSD) nis2ldap pam_captcha poor man's backup Solaris audio utility xboxproxy xdotool xmlpresenter xpathtool misc scripts

Presentations

Yahoo! Hack Day '06 Unix Essentials Vi/Vim Essentials

Tag Cloud

Calendar

< June 2007 >
SuMoTuWeThFrSa
      1 2
3 4 5 6 7 8 9
10111213141516
17181920212223
24252627282930

Friends

BarCamp Kent Brewster Tantek Çelik John Resig Wesley Shields Tyler Shields

Technorati