Sha256: 877ea81c1024bf1325d4da1c3bcafe254ff3bce32748b6b46c49bdf397ba74f4

Contents?: true

Size: 987 Bytes

Versions: 1

Compression:

Stored size: 987 Bytes

Contents

module Memo
  class Cli
    module Command
      class Preview
        def initialize(
          options,
          os: Memo::OS.new
        )
          @options = options
          @os = os
          @config = Memo::Config.new
          @today = Memo::Today.new
          @defaultfile = Memo::File.new
        end

        def call
          filename = @options[0]

          path = case filename
                 when "today", "t"
                   "#{@config.root}/#{@today.fullpath}"
                 when "config", "c"
                   @config.path
                 else
                   p = Memo::File.new(
                     filename,
                     @options.namespace,
                   ).fullpath

                   "#{@config.root}/#{p}"
                 end

          cmd ="#{@config.preview} #{path}"
          if @options.copy?
            @os.exec "#{cmd} | (#{@config.pbcopy})"
          end

          @os.exec cmd
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ememo-0.2.1 lib/memo/cli/command/preview.rb