Sha256: 46507de00e55f3dff5ce516d5a3d5df3a5aa71fd1af7351e4bafd8c688c7ec36

Contents?: true

Size: 987 Bytes

Versions: 3

Compression:

Stored size: 987 Bytes

Contents

# frozen_string_literal: true

module RubyJard
  module Commands
    ##
    # Show a screen
    class HideCommand < Pry::ClassCommand
      description 'Hide a screen'
      banner <<-BANNER
        Usage: jard hide [-h] [screen]
      BANNER
      match 'hide'

      def initialize(context = {})
        super(context)

        @screens = context[:screens] || RubyJard::Screens
        @config = context[:config] || RubyJard.config
      end

      def process
        screen = args.first.to_s.strip

        if screen.empty?
          raise Pry::CommandError,
                "Please input one of the following: #{@screens.names.join(', ')}"
        end

        unless @screens.names.include?(screen)
          raise Pry::CommandError,
                "Screen `#{screen}` not found. Please input one of the following: #{@screens.names.join(', ')}"
        end

        @config.enabled_screens.delete(screen)

        RubyJard::ControlFlow.dispatch(:list)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby_jard-0.3.1 lib/ruby_jard/commands/jard/hide_command.rb
ruby_jard-0.3.0 lib/ruby_jard/commands/jard/hide_command.rb
ruby_jard-0.2.3 lib/ruby_jard/commands/jard/hide_command.rb