Sha256: cc3f7bd43178187f5b964235f08b1d8f6a4e78a3353a448de2ea099d98976758

Contents?: true

Size: 809 Bytes

Versions: 3

Compression:

Stored size: 809 Bytes

Contents

module Birdwatcher
  module Commands
    class Unset < Birdwatcher::Command
      self.meta = {
        :description => "Unset module option",
        :names       => %w(unset),
        :usage       => "unset OPTION"
      }

      def run
        if !arguments?
          error("You must provide an option name")
          return false
        end

        if !current_module
          error("No module loaded")
          return false
        end

        option = arguments.first.upcase
        if !current_module.meta[:options].keys.include?(option)
          error("Unknown option: #{option.bold}")
          return false
        end

        current_module.meta[:options][option][:value] = nil
      end

      private

      def current_module
        console.current_module
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
birdwatcher-0.4.0 lib/birdwatcher/commands/unset.rb
birdwatcher-0.3.1 lib/birdwatcher/commands/unset.rb
birdwatcher-0.1.0 lib/birdwatcher/commands/unset.rb