Sha256: ea501bf6c87799881a7a6dded0f9006a164094fe212708890956dacc9bc510e2

Contents?: true

Size: 1.56 KB

Versions: 35

Compression:

Stored size: 1.56 KB

Contents

module Evertils
  module Controller
    class Get < Controller::Base
      attr_accessor :title, :file, :notebook

      def pre_exec
        # command flag parser
        OptionParser.new do |opt|
          opt.banner = "evertils new note [...-flags]"

          opt.on("-t", "--title=TITLE", "Set a custom title") do |title|
            @title = title
          end

          opt.on("-f", "--file=PATH", "Attach a file to your custom note") do |file|
            @file = file
          end

          opt.on("-n", "--notebook=PBOOK", "Attach a file to your custom note") do |notebook|
            @notebook = notebook
          end
        end.parse!

        super
      end

      # Get data about a notebook, prints titles of each child note
      def notebook
        if !$request.custom.nil?
          book = $request.custom[0]
          metadata = @model.notes_by_notebook(book)

          if metadata.is_a? ::Evernote::EDAM::NoteStore::NotesMetadataList
            Notify.info("#{metadata.totalNotes} notes in #{book}")
            Notify.info("Printing list of notes")

            metadata.notes.each do |note|
              Notify.spit note.title
            end
          else
            Notify.error("Could not pull data for notebook #{$request.custom[0]}", {})
          end
        else
          Notify.error("Notebook name is a required argument, i.e.\n#{Evertils::PACKAGE_NAME} get notebook agendas", {})
        end
      end

      def info
        @config.options.each_pair do |key, value|
          Notify.spit("#{key}: #{value}")
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
evertils-1.0.12 lib/evertils/controllers/get.rb
evertils-1.0.11 lib/evertils/controllers/get.rb
evertils-1.0.10 lib/evertils/controllers/get.rb
evertils-1.0.9 lib/evertils/controllers/get.rb
evertils-1.0.8 lib/evertils/controllers/get.rb
evertils-1.0.7 lib/evertils/controllers/get.rb
evertils-1.0.6 lib/evertils/controllers/get.rb
evertils-1.0.5 lib/evertils/controllers/get.rb
evertils-1.0.4 lib/evertils/controllers/get.rb
evertils-1.0.3 lib/evertils/controllers/get.rb
evertils-1.0.2 lib/evertils/controllers/get.rb
evertils-1.0.1 lib/evertils/controllers/get.rb
evertils-1.0.0 lib/evertils/controllers/get.rb
evertils-0.4.0 lib/evertils/controllers/get.rb
evertils-0.3.27 lib/evertils/controllers/get.rb
evertils-0.3.26 lib/evertils/controllers/get.rb
evertils-0.3.25 lib/evertils/controllers/get.rb
evertils-0.3.24 lib/evertils/controllers/get.rb
evertils-0.3.23 lib/evertils/controllers/get.rb
evertils-0.3.22 lib/evertils/controllers/get.rb