Handle argument parsing in C++
This commit is contained in:
parent
3f42909ecf
commit
b3ac48cf52
2 changed files with 13 additions and 18 deletions
|
@ -12,12 +12,23 @@
|
|||
|
||||
namespace {
|
||||
|
||||
bool OpenExternal(const GURL& url, mate::Arguments* args) {
|
||||
bool activate = true;
|
||||
if (args->Length() == 2) {
|
||||
mate::Dictionary options;
|
||||
if (args->GetNext(&options)) {
|
||||
options.Get("activate", &activate);
|
||||
}
|
||||
}
|
||||
return platform_util::OpenExternal(url, activate);
|
||||
}
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context, void* priv) {
|
||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||
dict.SetMethod("showItemInFolder", &platform_util::ShowItemInFolder);
|
||||
dict.SetMethod("openItem", &platform_util::OpenItem);
|
||||
dict.SetMethod("_openExternal", &platform_util::OpenExternal);
|
||||
dict.SetMethod("openExternal", &OpenExternal);
|
||||
dict.SetMethod("moveItemToTrash", &platform_util::MoveItemToTrash);
|
||||
dict.SetMethod("beep", &platform_util::Beep);
|
||||
}
|
||||
|
|
|
@ -1,17 +1 @@
|
|||
'use strict';
|
||||
|
||||
const bindings = process.atomBinding('shell');
|
||||
|
||||
exports.beep = bindings.beep;
|
||||
exports.moveItemToTrash = bindings.moveItemToTrash;
|
||||
exports.openItem = bindings.openItem;
|
||||
exports.showItemInFolder = bindings.showItemInFolder;
|
||||
|
||||
exports.openExternal = (url, options) => {
|
||||
var activate = true;
|
||||
if (options != null && options.activate != null) {
|
||||
activate = !!options.activate;
|
||||
}
|
||||
|
||||
return bindings._openExternal(url, activate);
|
||||
};
|
||||
module.exports = process.atomBinding('shell');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue