mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
a bit better arg handling...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
aaecdfa1e3
commit
f7d345b4ea
19
Viewer/e.js
19
Viewer/e.js
@ -23,6 +23,13 @@ var VERSION = require('./version').version
|
||||
var app = electron.app
|
||||
var BrowserWindow = electron.BrowserWindow
|
||||
|
||||
//
|
||||
global.ELECTRON_PACKAGED = app.isPackaged
|
||||
|
||||
// used to let e.js know that the CLI wants to start the GUI..
|
||||
global.START_GUI = false
|
||||
|
||||
|
||||
|
||||
|
||||
/*********************************************************************/
|
||||
@ -154,14 +161,10 @@ app.on('window-all-closed', function(){
|
||||
//---------------------------------------------------------------------
|
||||
// start things up...
|
||||
|
||||
global.START_GUI = false
|
||||
|
||||
var argv1 = process.argv[1]
|
||||
&& path.resolve(process.cwd(), process.argv[1])
|
||||
|
||||
;(process.argv.length > 2
|
||||
|| (argv1 && argv1 != require.main.filename)) ?
|
||||
// got some arguments -- trigger ig.js...
|
||||
;(ELECTRON_PACKAGED ?
|
||||
process.argv.length > 1
|
||||
: process.argv.length > 2) ?
|
||||
// got some arguments -- delegate to ig.js...
|
||||
(require('./ig')
|
||||
&& global.START_GUI
|
||||
&& start())
|
||||
|
||||
@ -117,6 +117,7 @@ var CLIActions = actions.Actions({
|
||||
var bar = state.bar =
|
||||
state.bar || container.create(0, 0, {text: text.padEnd(l)})
|
||||
|
||||
// XXX for some reason this does not work under electron...
|
||||
bar.setTotal(Math.max(max, value))
|
||||
bar.update(value)
|
||||
}],
|
||||
@ -178,7 +179,10 @@ var CLIActions = actions.Actions({
|
||||
// Startup commands...
|
||||
//
|
||||
startREPL: ['- System/Start CLI interpreter',
|
||||
{cli: '@repl'},
|
||||
{cli: {
|
||||
name: '@repl',
|
||||
interactive: true,
|
||||
}},
|
||||
function(){
|
||||
var that = this
|
||||
var repl = nodeRequire('repl')
|
||||
@ -214,6 +218,7 @@ var CLIActions = actions.Actions({
|
||||
// XXX move this to a feature that requires electron...
|
||||
// ...and move electron to an optional dependency...
|
||||
// XXX should we require electron or npx electron???
|
||||
// XXX add --dev-tools flag...
|
||||
startGUI: ['- System/Start viewer GUI',
|
||||
core.doc`
|
||||
|
||||
@ -469,12 +474,14 @@ module.CLI = core.ImageGridFeatures.Feature({
|
||||
function(){
|
||||
var that = this
|
||||
|
||||
//var pkg = require('package.json')
|
||||
var pkg = nodeRequire('./package.json')
|
||||
var wait_for = []
|
||||
// XXX
|
||||
var interactive = false
|
||||
|
||||
argv.Parser({
|
||||
context: this,
|
||||
script: nodeRequire.main.filename,
|
||||
|
||||
// XXX argv.js is not picking these up because
|
||||
// of the require(..) mixup...
|
||||
@ -511,6 +518,11 @@ module.CLI = core.ImageGridFeatures.Feature({
|
||||
action
|
||||
: (cmd.key || cmd.name)
|
||||
|
||||
// skip interactive commands in non-interactive
|
||||
// contexts...
|
||||
if(!interactive && cmd.interactive){
|
||||
return res }
|
||||
|
||||
res[name] = cmd instanceof argv.Parser ?
|
||||
// parser...
|
||||
cmd
|
||||
|
||||
@ -12,14 +12,12 @@ require('v8-compile-cache')
|
||||
// NOTE: this fixes several issues with lib/util conflicting with stuff...
|
||||
require('repl')
|
||||
|
||||
|
||||
// setup module loaders...
|
||||
require = require('./cfg/requirejs')(require).requirejs
|
||||
require.main = {filename: (nodeRequire.main || {}).filename}
|
||||
|
||||
|
||||
|
||||
/*********************************************************************/
|
||||
|
||||
var core = require('features/core')
|
||||
// XXX for some reason if this is not loaded here things break in CLI...
|
||||
// ...setting priority does not help...
|
||||
@ -28,7 +26,7 @@ var meta = require('features/meta')
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
/*********************************************************************/
|
||||
|
||||
// NOTE: this is here to simplify importing...
|
||||
var ImageGridFeatures =
|
||||
|
||||
12
Viewer/package-lock.json
generated
12
Viewer/package-lock.json
generated
@ -1127,9 +1127,9 @@
|
||||
}
|
||||
},
|
||||
"ig-argv": {
|
||||
"version": "2.16.2",
|
||||
"resolved": "https://registry.npmjs.org/ig-argv/-/ig-argv-2.16.2.tgz",
|
||||
"integrity": "sha512-bSOslxGN9XqJ+IVba/XC0h9p1r/z/25wmJ2ik2xCNlMU07WI/K2ensIFR93I0aVfLHxsV37G5CdlP8xmiRIcLg==",
|
||||
"version": "2.16.3",
|
||||
"resolved": "https://registry.npmjs.org/ig-argv/-/ig-argv-2.16.3.tgz",
|
||||
"integrity": "sha512-58WBfqqXNL6KV4CaSVmFAizqYd0ymGANe0F+d/Zue2JHXOpolB6jwY0glrzU09THZjipnNnB+LlUxYwcwDeTwA==",
|
||||
"requires": {
|
||||
"ig-object": "^5.2.6"
|
||||
}
|
||||
@ -1861,6 +1861,12 @@
|
||||
"strip-json-comments": "~2.0.1"
|
||||
}
|
||||
},
|
||||
"rcedit": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/rcedit/-/rcedit-2.3.0.tgz",
|
||||
"integrity": "sha512-h1gNEl9Oai1oijwyJ1WYqYSXTStHnOcv1KYljg/8WM4NAg3H1KBK3azIaKkQ1WQl+d7PoJpcBMscPfLXVKgCLQ==",
|
||||
"dev": true
|
||||
},
|
||||
"readable-stream": {
|
||||
"version": "2.3.7",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz",
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
"glob": "^7.1.6",
|
||||
"guarantee-events": "^1.0.0",
|
||||
"ig-actions": "^3.24.22",
|
||||
"ig-argv": "^2.16.2",
|
||||
"ig-argv": "^2.16.3",
|
||||
"ig-features": "^3.4.2",
|
||||
"ig-object": "^5.4.12",
|
||||
"ig-types": "^5.0.40",
|
||||
@ -55,7 +55,8 @@
|
||||
"devDependencies": {
|
||||
"asar": "^3.0.1",
|
||||
"electron-rebuild": "^1.11.0",
|
||||
"less": "^3.13.0"
|
||||
"less": "^3.13.0",
|
||||
"rcedit": "*"
|
||||
},
|
||||
"bin": {
|
||||
"ig": "ig.js"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user