Sha256: 298787a12bce7ab0b2b01e9915db2e6ebd7fbddc88b078692702fe560cfe35a4

Contents?: true

Size: 1.73 KB

Versions: 3

Compression:

Stored size: 1.73 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/summary_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 'summary'
                  SummaryCommand
                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

3 entries across 3 versions & 1 rubygems

Version Path
markdo-0.1.7 lib/markdo/cli.rb
markdo-0.1.6 lib/markdo/cli.rb
markdo-0.1.5 lib/markdo/cli.rb