Sha256: 4e5d1ec546e225a0900c471c1f5eecbada676b5ba291689de7a8dd1de0439645

Contents?: true

Size: 867 Bytes

Versions: 4

Compression:

Stored size: 867 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"
                   @today.fullpath
                 else
                   Memo::File.new(
                     filename,
                     @options.namespace,
                   ).fullpath
                 end

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

          @os.exec cmd
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ememo-0.1.8 lib/memo/cli/command/preview.rb
ememo-0.1.7 lib/memo/cli/command/preview.rb
ememo-0.1.6 lib/memo/cli/command/preview.rb
ememo-0.1.5 lib/memo/cli/command/preview.rb