Skip to content

Commit

Permalink
impl loading initial behavior and updated package.json version
Browse files Browse the repository at this point in the history
  • Loading branch information
TakashiSato committed Nov 10, 2023
1 parent f7d1a34 commit 74a0e4c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "FlexBE App",
"version": "2.3.0",
"version": "2.4.1",
"main": "src/main.js",
"window": {
"icon": "src/img/icon-128.png",
Expand Down
36 changes: 36 additions & 0 deletions src/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,40 @@ window.onload = function() {
CheckBehaviorsReport.checkAllBehaviors(gui.App.quit);
}, 5 * 1000);
}

//-----------------------------------------------------------------
// load behavior from command line argument (by Takashi Sato 2023/11/10)
function getCommandLineArguments() {
let args = {};
argv = gui.App.argv.toString()
argv.split(',').forEach((val, index) => {
// "--key=value" 形式の引数を解析
if (val.startsWith('--')) {
let [key, value] = val.slice(2).split('=');
args[key] = value;
console.log(`key: ${key}, value: ${value}`)
}
});
return args;
}

const args = getCommandLineArguments();
if ("behavior" in args) {
behaviorName = args["behavior"]

let retry = 0;
function loadInitialBehavior() {
try {
var manifest = WS.Behaviorlib.getByName(behaviorName).getBehaviorManifest();
IO.BehaviorLoader.loadBehavior(manifest);
} catch (e) {
if (retry < 10) {
setTimeout(loadInitialBehavior, 500);
retry++;
}
}
}
setTimeout(loadInitialBehavior, 100);
}
//-----------------------------------------------------------------
}

0 comments on commit 74a0e4c

Please sign in to comment.