This repository has been archived by the owner on Jun 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
64 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#! /usr/bin/env node | ||
/** | ||
* XadillaX created at 2015-08-05 14:14:18 With ♥ | ||
* | ||
* Copyright (c) 2015 Huaban.com, all rights | ||
* reserved. | ||
*/ | ||
var opts = require("nomnom").script("illyria").option("host", { | ||
abbr: "h", | ||
default: "127.0.0.1", | ||
help: "the server host" | ||
}).option("port", { | ||
abbr: "p", | ||
default: 3721, | ||
help: "the server port" | ||
}).option("module", { | ||
abbr: "m", | ||
required: true, | ||
help: "the send module" | ||
}).option("function", { | ||
abbr: "f", | ||
required: true, | ||
help: "the send function" | ||
}).option("data", { | ||
abbr: "d", | ||
default: "{}", | ||
help: "the send data" | ||
}).option("runTimeout", { | ||
abbr: "t", | ||
default: 10000, | ||
help: "the run timeout" | ||
}).parse(); | ||
|
||
var Illyria = require("../"); | ||
var TermColor = require("term-color"); | ||
|
||
var client = Illyria.createClient(opts.host, opts.port); | ||
client.connect(function() { | ||
var data; | ||
try { | ||
data = JSON.parse(opts.data); | ||
} catch(e) { | ||
data = opts.data; | ||
} | ||
|
||
client.send(opts.module, opts.function, data, function(err, data) { | ||
if(err) { | ||
console.error(TermColor.red("Failed!")); | ||
console.error(err.message); | ||
process.exit(4); | ||
} else { | ||
console.log(TermColor.green("Succeeded!")); | ||
console.log(data); | ||
process.exit(0); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters