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 16 17 18 19 |
# File 'lib/subcommands/tags.rb', line 4 def add(tag) tag = ::Tag.new(tag: tag.strip) if !tag.save output do tag.errors..each do |error| say error, :red end end exit end output do say tag.tag + " added!", :green end end |
#ls ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/subcommands/tags.rb', line 37 def ls = ::Tag.order([:order].to_sym => :desc) if .size == 0 output do say "No tags found", :red end end table = [['#', 'name', 'logs']] # header .each do |tag| table << [tag.id, tag.tag, tag.logs.count] # row end output do print_table table end end |
#rm(tag) ⇒ Object
option :prune, :type => :boolean, :alias => ‘-p’, :default => false not implemented yet
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/subcommands/tags.rb', line 23 def rm(tag) tag = ::Tag.find_by!(tag: tag) output do if tag.destroy say "Tag #{tag.tag} destroyed forever", :green else say "Tag #{tag.tag} could not be destroyed", :red end end end |