Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #2 knife joyent tag list <server>
- Loading branch information
Kevin Chan
committed
Apr 11, 2012
1 parent
8125c7c
commit c7b32dc
Showing
1 changed file
with
35 additions
and
0 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,35 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/base') | ||
|
||
module KnifeJoyent | ||
class JoyentTagList < Chef::Knife | ||
|
||
include KnifeJoyent::Base | ||
|
||
banner "knife joyent tag list <server>" | ||
|
||
def run | ||
server = name_args.first | ||
|
||
unless server | ||
show_usage | ||
exit 1 | ||
end | ||
|
||
tags = [ | ||
ui.color('Name', :bold), | ||
ui.color('Value', :bold), | ||
] | ||
|
||
self.connection.servers.get(server).tags.each do |k, v| | ||
tags << k | ||
tags << v | ||
end | ||
|
||
puts ui.list(tags, :uneven_columns_across, 2) | ||
exit 0 | ||
rescue Excon::Errors::NotFound => e | ||
puts ui.error("Server #{server} not found") | ||
exit 1 | ||
end | ||
end | ||
end |