Class: TrakFlow::CLI::DepCommands
- Inherits:
-
Thor
- Object
- Thor
- TrakFlow::CLI::DepCommands
- Defined in:
- lib/trak_flow/cli/dep_commands.rb
Overview
Dependency subcommands
Instance Method Summary collapse
Instance Method Details
#add(source, target) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/trak_flow/cli/dep_commands.rb', line 11 def add(source, target) with_database do |db| dep = Models::Dependency.new( source_id: source, target_id: target, type: [:type] ) db.add_dependency(dep) output(dep.to_h) do puts "Added dependency: #{source} #{options[:type]} #{target}" end end end |
#remove(source, target) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/trak_flow/cli/dep_commands.rb', line 28 def remove(source, target) with_database do |db| count = db.remove_dependency(source, target, type: [:type]) output({ removed: count }) do puts "Removed #{count} dependency(ies)" end end end |
#tree(id) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/trak_flow/cli/dep_commands.rb', line 39 def tree(id) with_database do |db| graph = Graph::DependencyGraph.new(db) tree_data = graph.dependency_tree(id) output(tree_data) do print_tree(tree_data, 0) end end end |