diff --git a/lib/api/tag.js b/lib/api/tag.js index e376b8c..5d0e634 100644 --- a/lib/api/tag.js +++ b/lib/api/tag.js @@ -210,4 +210,52 @@ module.exports = { create: create, update: update, "delete": delete_tags, + getUsage: function(){ + return [ + "${command} tag get_all [--source ]", + "${command} tag get [--source ] [--by-source]", + "${command} tag delete [--source ]", + "${command} tag create [--source ]", + "${command} tag update [--source ]" + ]; + }, + getHelp: function(){ + return [ + "Tag Commands:", + " get_all get all tags", + " get get all tags for a given host", + " delete delete tags for a given host", + " create add the comma separates \"tag:value\"'s from to ", + " update update the comma separates \"tag:value\"'s from to ", + "", + "Tag Options:", + " --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); + } + } }