teslajs
Version:
Full-featured Tesla REST API NodeJS package
42 lines (36 loc) • 1.2 kB
JavaScript
//=====================================================================
// This sample demonstrates using TeslaJS
//
// https://github.com/mseminatore/TeslaJS
//
// Copyright (c) 2016 Mark Seminatore
//
// Refer to included LICENSE file for usage rights and restrictions
//=====================================================================
;
require('colors');
var program = require('commander');
var framework = require('./sampleFramework.js');
//
//
//
program
.option('-u, --username [string]', 'username (needed only if token not cached)')
.option('-p, --password [string]', 'password (needed only if token not cached)')
.option('-U, --uri [string]', 'URI of test server (e.g. http://127.0.0.1:3000)')
.option('-v, --verbose', 'show detailed results')
.parse(process.argv);
//
var sample = new framework.SampleFramework(program, sampleMain);
sample.run();
//
//
//
function sampleMain(tjs, options) {
tjs.productsAsync(options).then( function(products) {
console.log("\nTesla products returned: " + products.length + "\n");
if (program.verbose) {
console.log(products);
}
});
}