Sha256: e7e84a6c948669c7d8eeb36d3ca8688a2d7b8bf59832fd96cba51c35c9f27a83

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

#!/usr/bin/env ruby

require 'bundler'
Bundler.require

require 'trollop'

def log(msg)
  STDERR.puts "#{File.basename($0)}: #{msg}"
end

def die(msg = nil)
  log(msg) unless msg.nil?
  exit 1
end

opts = Trollop::options do
  version "#{File.basename($0)} v#{TaskWarrior::Dependencies::VERSION} (c) 2012 Nicolas E. Rabenau"
  banner <<-EOS
Visualizes dependencies between TaskWarrior tasks.

Usage:
       #{File.basename($0)} [options]

where [options] are:

EOS
  opt :format, "Specify output format", :default => 'svg'
  opt :title,  "Specify title", :default => 'Task Dependencies'
  opt :trace,  "Enable trace output", :default => false
end

include TaskWarrior
include TaskWarrior::Dependencies

Trollop::die :format, "must be one of #{Graph.formats.join(', ')}" unless Graph.formats.include?(opts[:format])

begin
  repo = Repository.new(ARGF.read)
  master = Graph.new(Presenter.new(opts[:title]))

  # Add all projects (will add their tasks and dependencies recursively)
  repo.projects.each do |project|
    master << project
  end

  # Add all project-less tasks as toplevel nodes
  repo.tasks.reject{|t| t.project}.each do |task|
    master << task
  end

  puts master.render(opts[:format])
rescue
  if opts[:trace]
    log($!)
    $@.each{|line| log(line)}
  else
    die($!)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
twdeps-0.0.3 bin/twdeps