Sha256: 65bff650a4f4ce39a08442f571f21b858358634865f4e7aa9384642cf1026d66

Contents?: true

Size: 1.63 KB

Versions: 1

Compression:

Stored size: 1.63 KB

Contents

require 'markdo/add_command'
require 'markdo/edit_command'
require 'markdo/help_command'
require 'markdo/ics_command'
require 'markdo/overview_command'
require 'markdo/query_command'
require 'markdo/rss_command'
require 'markdo/star_command'
require 'markdo/tag_command'
require 'markdo/today_command'
require 'markdo/tomorrow_command'
require 'markdo/version_command'

module Markdo
  class CLI
    def initialize(stdout, stderr, full_env)
      @stdout = stdout
      @stderr = stderr
      @full_env = full_env
    end

    def run(command_name = 'help', *args)
      command = case command_name
                when 'add'
                  AddCommand
                when 'edit'
                  EditCommand
                when 'ics'
                  IcsCommand
                when 'overdue'
                  OverdueCommand
                when 'overview'
                  OverviewCommand
                when 'query', 'q'
                  QueryCommand
                when 'rss'
                  RssCommand
                when 'star', 'starred'
                  StarCommand
                when 'tag'
                  TagCommand
                when 'today'
                  TodayCommand
                when 'tomorrow'
                  TomorrowCommand
                when 'version', '--version'
                  VersionCommand
                else
                  HelpCommand
                end

      command.new(@stdout, @stderr, env).run(*args)
    end

    private

    def default_env
      {
        'MARKDO_ROOT' => '.',
        'MARKDO_INBOX' => 'Inbox.md',
      }
    end

    def env
      default_env.merge(@full_env)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
markdo-0.1.4 lib/markdo/cli.rb