Class: SubCommands::Tags
- Inherits:
-
Thor
- Object
- Thor
- SubCommands::Tags
- Defined in:
- lib/subcommands/tags.rb
Instance Method Summary collapse
- #add(tag) ⇒ Object
- #ls ⇒ Object
-
#rm(tag) ⇒ Object
option :prune, :type => :boolean, :alias => ‘-p’, :default => false not implemented yet.
Instance Method Details
#add(tag) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/subcommands/tags.rb', line 4 def add(tag) tag = ::Tag.new(tag: tag.strip) if !tag.save tag.errors..each do |error| say error, :red end exit 1 end say tag.tag + " added!", :green end |
#ls ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/subcommands/tags.rb', line 27 def ls = ::Tag.order([:order].to_sym => :desc) table = [['#', 'name', 'logs']] # header .each do |tag| table << [tag.id, tag.tag, tag.logs.count] # row end print_table table end |
#rm(tag) ⇒ Object
option :prune, :type => :boolean, :alias => ‘-p’, :default => false not implemented yet
19 20 21 22 23 |
# File 'lib/subcommands/tags.rb', line 19 def rm(tag) tag = ::Tag.find_by!(tag: tag) tag.destroy say ["Tag", tag.tag, "destroyed forever"].join(' '), :green end |