Class: TrakFlow::CLI::AdminCommands
- Inherits:
-
Thor
- Object
- Thor
- TrakFlow::CLI::AdminCommands
- Defined in:
- lib/trak_flow/cli/admin_commands.rb
Overview
Admin subcommands
Instance Method Summary collapse
Instance Method Details
#analyze ⇒ Object
77 78 79 80 81 82 |
# File 'lib/trak_flow/cli/admin_commands.rb', line 77 def analyze with_database do |db| analysis = Graph::DependencyGraph.new(db).analyze output(analysis) { print_analysis(analysis) } end end |
#cleanup ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/trak_flow/cli/admin_commands.rb', line 14 def cleanup with_database do |db| candidates = cleanup_candidates(db) count = candidates.size if candidates.empty? puts "No tasks to clean up" return end return print_cleanup_dry_run(candidates) if [:dry_run] return unless [:force] || confirm_cleanup?(count) delete_candidates(db, candidates) output({ deleted: count }) do puts "Deleted #{count} task(s)" end end end |
#compact ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/trak_flow/cli/admin_commands.rb', line 38 def compact with_database do |db| if [:analyze] stats = compaction_stats(db) output(stats) do stats.each { |k, v| puts "#{k}: #{v}" } end elsif [:apply] tombstone_old_closed_tasks(db) puts "Compaction complete" else puts "Use --analyze to see stats or --apply to compact" end end end |
#graph ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/trak_flow/cli/admin_commands.rb', line 58 def graph with_database do |db| dep_graph = Graph::DependencyGraph.new(db) graph_output = case [:format] when "svg" then dep_graph.to_svg(include_closed: [:include_closed]) else dep_graph.to_dot(include_closed: [:include_closed]) end if (output_path = [:output]) File.write(output_path, graph_output) puts "Graph written to #{output_path}" else puts graph_output end end end |