Sha256: 81004cdfae2fc3c2dd30d9465f79e9e3e5b79235f9197d4a54a3acf4225f9728

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

class Shoes
  module UI
    class CLI
      class DefaultCommand < BaseCommand
        def run
          if parse!(args)
            warn_on_unexpected_parameters

            path = args.first
            if path
              $LOAD_PATH.unshift(File.dirname(path))
              Shoes.configuration.app_dir = File.dirname(path)
              load path
            end
          end
        end

        def options
          OptionParser.new do |opts|
            # Keep around command dashed options
            opts.on('-v', '--version', 'Shoes version') do
              Shoes::UI::CLI::VersionCommand.new([]).run
              exit
            end

            opts.on('-h', '--help', 'Shoes help') do
              Shoes::UI::CLI::HelpCommand.new([]).run
              exit
            end

            # Also, we have some real runtime options!
            opts.on('-f', '--fail-fast', 'Crash on exceptions in Shoes code') do
              Shoes.configuration.fail_fast = true
            end
          end
        end

        def help
          help_from_options("shoes [options] file", options)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shoes-core-4.0.0.rc1 lib/shoes/ui/cli/default_command.rb