Sha256: 2ba5d3f4125f8d4dbab893e5b30c0d7c117d62ed32aac212a5fe2ffb812ad8cc

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'thor'
require 'wunderlist_to_github/source'
require 'wunderlist_to_github/sink'

# Command-line interface for converting Wunderlist tasks to GitHub issues.
class WlToGhCLI < Thor
  def initialize(*args)
    @wl = WunderlistToGithub::WunderlistSource.new(
      ENV['WUNDERLIST_CLIENT_ID'],
      ENV['WUNDERLIST_ACCESS_TOKEN']
    )
    @gh = WunderlistToGithub::GitHubSink.new(
      ENV['GITHUB_LOGIN'],
      ENV['GITHUB_API_TOKEN']
    )
    super(*args)
  end

  desc 'tasks LISTNAME', "List tasks' titles in Wunderlist LISTNAME"
  def tasks(list_name)
    puts @wl.tasks(list_name).map(&:title)
  end

  desc 'convert LISTNAME USER REPONAME',
       'Converts Wunderlist tasks in LISTNAME to GitHub issues in USER/REPONAME'
  def convert(list_name, user, repo_name)
    tasks = @wl.tasks(list_name)
    num_tasks = tasks.length
    STDERR.puts "Converting #{num_tasks} tasks from #{list_name} " \
                "to #{repo_name}"
    num_converted = 0
    @gh.convert(tasks, user, repo_name) do |t|
      num_converted += 1
      STDERR.puts "Converted #{t[:title]} (#{num_converted}/#{num_tasks})."
    end
  end
end

WlToGhCLI.start(ARGV)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wunderlist_to_github-0.1.1 exe/wunderlist_to_github