Class: Tagm::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/tagm/cli.rb

Instance Method Summary collapse

Instance Method Details

#create_dbObject



53
54
55
56
# File 'lib/tagm/cli.rb', line 53

def create_db
  puts "Creating database at #{Config::DB_PATH_VAR}"
  Tagm::Db.create_database!
end

#mergeObject



47
48
49
50
# File 'lib/tagm/cli.rb', line 47

def merge
  Db.merge(from: options[:from], into: options[:into])
  puts "Merged \"#{options[:from].sort.join('", "')}\" into \"#{options[:into]}\""
end

#on(node = nil) ⇒ Object



30
31
32
33
34
# File 'lib/tagm/cli.rb', line 30

def on(node = nil)
  path = resolve_path(node)

  put_path_tags path, node
end

#tag(node) ⇒ Object



13
14
15
16
17
18
# File 'lib/tagm/cli.rb', line 13

def tag(node)
  path = resolve_path node
  Db.tag node: path, tags: options[:tags]

  put_path_tags path, node
end

#tagged(tags = []) ⇒ Object



37
38
39
40
41
42
# File 'lib/tagm/cli.rb', line 37

def tagged(tags = [])
  paths = Db.list(*tags)
  paths.each_pair do |path, list|
    puts "#{path}: #{colorize(list).join(', ')}"
  end
end

#untag(node) ⇒ Object



22
23
24
25
26
27
# File 'lib/tagm/cli.rb', line 22

def untag(node)
  path = resolve_path node
  Db.untag node: path, tags: options[:tags]

  put_path_tags path, node
end