Browse Source

actually implement cli for timeboards

pull/14/head
Brett Langdon 11 years ago
parent
commit
8ce1fb2e95
1 changed files with 35 additions and 6 deletions
  1. +35
    -6
      lib/api/timeboard.js

+ 35
- 6
lib/api/timeboard.js View File

@ -230,16 +230,45 @@ module.exports = {
return [
"Timeboard:",
" Subcommands:",
" get <dash-id>",
" getall",
" remove <dash-id>",
" create <title> <description> <graphs>",
" update <dash-id> <title> <description> <graphs>",
" get <dash-id> get an existing timeboard",
" getall get all existing timeboards",
" remove <dash-id> remove an existing timeboard",
" create <title> <description> <graphs> create a new timeboard, <graphs> is a json of the graphs definition",
" update <dash-id> <title> <description> <graphs> update an existing timeboard, <graphs> is a json of the graphs definition",
" Options:",
" --tmpvars <templateVariables>"
" --tmpvars <templateVariables> a json representation of the template variables definition"
];
},
handleCli: function(subcommand, args, callback){
if(subcommand === "get"){
get(args._[4], callback);
} else if(subcommand === "getall"){
getAll(callback);
} else if(subcommand === "remove"){
remove(args._[4], callback);
} else if(subcommand === "create"){
var title = args._[4];
var description = args._[5];
var graphs = JSON.parse(args._[6]);
var templateVariables = [];
if(args["tmpvars"]){
templateVariables = JSON.parse(args["tmpvars"]);
}
create(title, description, graphs, templateVariables, callback);
} else if(subcommand === "update"){
var dashId = parseInt(args._[4]);
var title = args._[5];
var description = args._[6];
var graphs = JSON.parse(args._[7]);
var templateVariables = [];
if(args["tmpvars"]){
templateVariables = JSON.parse(args["tmpvars"]);
}
update(dashId, title, description, graphs, templateVariables, callback);
} else {
callback("unknown subcommand or arguments try `dogapi timeboard --help` for help", false);
}
}
};

Loading…
Cancel
Save