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 {
|
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,
|
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||||
v8::Local<v8::Context> context, void* priv) {
|
v8::Local<v8::Context> context, void* priv) {
|
||||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||||
dict.SetMethod("showItemInFolder", &platform_util::ShowItemInFolder);
|
dict.SetMethod("showItemInFolder", &platform_util::ShowItemInFolder);
|
||||||
dict.SetMethod("openItem", &platform_util::OpenItem);
|
dict.SetMethod("openItem", &platform_util::OpenItem);
|
||||||
dict.SetMethod("_openExternal", &platform_util::OpenExternal);
|
dict.SetMethod("openExternal", &OpenExternal);
|
||||||
dict.SetMethod("moveItemToTrash", &platform_util::MoveItemToTrash);
|
dict.SetMethod("moveItemToTrash", &platform_util::MoveItemToTrash);
|
||||||
dict.SetMethod("beep", &platform_util::Beep);
|
dict.SetMethod("beep", &platform_util::Beep);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1 @@
|
||||||
'use strict';
|
module.exports = process.atomBinding('shell');
|
||||||
|
|
||||||
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);
|
|
||||||
};
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue