Skip to content

Commit

Permalink
give commandline opts precedence over rc files, closes #27
Browse files Browse the repository at this point in the history
  • Loading branch information
letsgetrandy committed Jan 11, 2014
1 parent 8b5c1ad commit c775db2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 30 deletions.
12 changes: 0 additions & 12 deletions src/chrome/components/commandline.js
Expand Up @@ -93,18 +93,6 @@ CommandLine.prototype = {
}
cmdLine.removeArguments(0, argc - 1);


/*
* TODO: superfluous
if (configuration.args[0].substr(0, 1) == '-') {
Components.utils.reportError("unknown option " +
configuration.args[0]);
dump("unknown option " + configuration.args[0] + " \n");
cmdLine.preventDefault = true;
return;
}
*/

/*
* TODO: should loop in the processing function, not here
*
Expand Down
26 changes: 13 additions & 13 deletions src/chrome/components/configuration.jsm
Expand Up @@ -34,11 +34,9 @@ var NSGetFactory = XPCOMUtils.generateNSGetFactory([specter_configuration]);
/* ---------------------------------------------------------------------- */
/* Template. No need to modify the code below. */

const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
const loader = Cc['@mozilla.org/moz/jssubscript-loader;1']
.getService(Ci.mozIJSSubScriptLoader);
const loader =
Components.classes['@mozilla.org/moz/jssubscript-loader;1']
.getService(Components.interfaces.mozIJSSubScriptLoader);

function Component() {
this.wrappedJSObject = this;
Expand All @@ -51,8 +49,8 @@ Component.prototype = {

QueryInterface: function(aIID) {
if(!aIID.equals(INTERFACE) &&
!aIID.equals(Ci.nsISupports))
throw Cr.NS_ERROR_NO_INTERFACE;
!aIID.equals(Components.interfaces.nsISupports))
throw Components.results.NS_ERROR_NO_INTERFACE;
return this;
}
};
Expand All @@ -61,7 +59,7 @@ loader.loadSubScript(SOURCE, Component.prototype);
var Factory = {
createInstance: function(aOuter, aIID) {
if(aOuter != null)
throw Cr.NS_ERROR_NO_AGGREGATION;
throw Components.results.NS_ERROR_NO_AGGREGATION;
var component = new Component();
if(typeof(component.init) == 'function')
component.init();
Expand All @@ -78,24 +76,26 @@ var Module = {
this._firstTime = false;
throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
};
aCompMgr = aCompMgr.QueryInterface(Ci.nsIComponentRegistrar);
aCompMgr = aCompMgr.QueryInterface(
Components.interfaces.nsIComponentRegistrar);
aCompMgr.registerFactoryLocation(
CLASS_ID, CLASS_NAME, CONTRACT_ID, aFileSpec, aLocation, aType);
},

unregisterSelf: function(aCompMgr, aLocation, aType) {
aCompMgr = aCompMgr.QueryInterface(Ci.nsIComponentRegistrar);
aCompMgr = aCompMgr.QueryInterface(
Components.interfaces.nsIComponentRegistrar);
aCompMgr.unregisterFactoryLocation(CLASS_ID, aLocation);
},

getClassObject: function(aCompMgr, aCID, aIID) {
if (!aIID.equals(Ci.nsIFactory))
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
if (!aIID.equals(Components.interfaces.nsIFactory))
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;

if (aCID.equals(CLASS_ID))
return Factory;

throw Cr.NS_ERROR_NO_INTERFACE;
throw Components.results.NS_ERROR_NO_INTERFACE;
},

canUnload: function(aCompMgr) { return true; }
Expand Down
9 changes: 4 additions & 5 deletions src/chrome/modules/configuration.jsm
Expand Up @@ -28,6 +28,10 @@ var currentSection = '';

function init() {
diffdir.append('specter');
findIniFiles();

// TODO: check env here?

for (var i=0; i< configuration.opts.length; i++) {
var m = configuration.opts[i].match(/--([^=\s]+)=([^\s]+)/);
if (m) {
Expand All @@ -37,11 +41,6 @@ function init() {
setflag(m[1]);
}
}
findIniFiles();

// check env

// check commandline
}

function setopt(k, v) {
Expand Down

0 comments on commit c775db2

Please sign in to comment.