|
|
@ -210,4 +210,52 @@ module.exports = { |
|
|
create: create, |
|
|
create: create, |
|
|
update: update, |
|
|
update: update, |
|
|
"delete": delete_tags, |
|
|
"delete": delete_tags, |
|
|
|
|
|
getUsage: function(){ |
|
|
|
|
|
return [ |
|
|
|
|
|
"${command} tag get_all [--source <source>]", |
|
|
|
|
|
"${command} tag get <host> [--source <source>] [--by-source]", |
|
|
|
|
|
"${command} tag delete <host> [--source <source>]", |
|
|
|
|
|
"${command} tag create <host> <tags> [--source <source>]", |
|
|
|
|
|
"${command} tag update <host> <tags> [--source <source>]" |
|
|
|
|
|
]; |
|
|
|
|
|
}, |
|
|
|
|
|
getHelp: function(){ |
|
|
|
|
|
return [ |
|
|
|
|
|
"Tag Commands:", |
|
|
|
|
|
" get_all get all tags", |
|
|
|
|
|
" get <host> get all tags for a given host", |
|
|
|
|
|
" delete <host> delete tags for a given host", |
|
|
|
|
|
" create <host> <tags> add the comma separates \"tag:value\"'s from <tag> to <host>", |
|
|
|
|
|
" update <host> <tags> update the comma separates \"tag:value\"'s from <tag> to <host>", |
|
|
|
|
|
"", |
|
|
|
|
|
"Tag Options:", |
|
|
|
|
|
" --source <source> the source of the tags (e.g. \"chef\", \"user\", \"jenkins\", etc)", |
|
|
|
|
|
" --by-source whether the results should be grouped by source" |
|
|
|
|
|
]; |
|
|
|
|
|
}, |
|
|
|
|
|
handleCli: function(subcommand, args, callback){ |
|
|
|
|
|
var source = args["source"]; |
|
|
|
|
|
var host = args._[4]; |
|
|
|
|
|
|
|
|
|
|
|
if(subcommand === "get_all"){ |
|
|
|
|
|
get_all(source, callback); |
|
|
|
|
|
} else if(subcommand === "get"){ |
|
|
|
|
|
var options = {}; |
|
|
|
|
|
if(source){ |
|
|
|
|
|
options.source = source; |
|
|
|
|
|
} |
|
|
|
|
|
if(args["by-source"]){ |
|
|
|
|
|
options.by_source = true; |
|
|
|
|
|
} |
|
|
|
|
|
get(host, options, callback); |
|
|
|
|
|
} else if(subcommand === "create"){ |
|
|
|
|
|
var tags = args._[5].split(","); |
|
|
|
|
|
create(host, tags, source, callback); |
|
|
|
|
|
} else if(subcommand === "update"){ |
|
|
|
|
|
var tags = args._[5].split(","); |
|
|
|
|
|
update(host, tags, source, callback); |
|
|
|
|
|
} else if(subcommand === "delete"){ |
|
|
|
|
|
delete_tags(host, source, callback); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |