Skip to content

Commit

Permalink
refactoring topic command
Browse files Browse the repository at this point in the history
  • Loading branch information
forresty committed Apr 19, 2012
1 parent 120cb51 commit ae70dce
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions bin/v2ex
Expand Up @@ -28,11 +28,7 @@ command :topic do |c|
c.action do |args, options| c.action do |args, options|
topic_id = args.first.to_i topic_id = args.first.to_i
print_topic V2exCli::Engine.topic(topic_id), :show_content => true print_topic V2exCli::Engine.topic(topic_id), :show_content => true
info "\nreplies:\n" print_topic_replies V2exCli::Engine.replies(topic_id)
V2exCli::Engine.replies(topic_id).each do |reply|
puts "#{reply[:member][:username]} ".ljust(25, '-')
print "#{reply[:content]}\n\n"
end
end end
end end


Expand Down Expand Up @@ -71,6 +67,19 @@ command :nodes do |c|
end end
end end


def print_topic_replies(replies)
info "\nreplies:\n"

if replies.empty?
puts "No replies yet."
else
replies.each do |reply|
puts "#{reply[:member][:username]} ".ljust(25, '-')
print "#{reply[:content]}\n\n"
end
end
end

def print_user_meta(user) def print_user_meta(user)
puts "#{user[:username]} - V2EX Member ##{user[:id]}" puts "#{user[:username]} - V2EX Member ##{user[:id]}"
%w{twitter website location tagline}.map(&:to_sym).each do |key| %w{twitter website location tagline}.map(&:to_sym).each do |key|
Expand Down

0 comments on commit ae70dce

Please sign in to comment.