Sha256: d29788d6c152ee1b77b9cc7bc63f740c44fce996d60b475f36b057fe1f63d660

Contents?: true

Size: 1.87 KB

Versions: 18

Compression:

Stored size: 1.87 KB

Contents

require 'irb'
require 'irb/completion'

ARGV << '--help' if ARGV.empty?

aliases = {
  'i' => 'interactive',
  'f' => 'fetch'
}

command = ARGV.shift
command = aliases[command] || command

require 'origen/global_methods'
include Origen::GlobalMethods

if ARGV.delete('-d') || ARGV.delete('--debug')
  begin
    if RUBY_VERSION >= '2.0.0'
      require 'byebug'
    else
      require 'rubygems'
      require 'ruby-debug'
    end
  rescue LoadError
    def debugger
      caller[0] =~ /.*\/(\w+\.rb):(\d+).*/
      puts 'The debugger gem is not installed, add the following to your Gemfile:'
      puts
      puts "if RUBY_VERSION >= '2.0.0'"
      puts "  gem 'byebug', '~>3.5'"
      puts 'else'
      puts "  gem 'debugger', '~>1.6'"
      puts 'end'
      puts
    end
  end
  Origen.enable_debugger
else
  def debugger
    caller[0] =~ /.*\/(\w+\.rb):(\d+).*/
    puts "#{Regexp.last_match[1]}:#{Regexp.last_match[2]} - debugger statement ignored, run again with '-d' to enable it"
  end
end

case command

when 'new'
  require 'origen/commands/new'

when '--version', '-v'
  require 'origen/commands/version'

when 'fetch', 'f'
  require 'origen/commands/fetch'

when 'interactive'
  IRB.start

else
  puts 'Error: Command not recognized' unless ['-h', '--help'].include?(command)
  puts <<-EOT
Usage: origen COMMAND [ARGS]

The following commands are available:
 new          Create a new Origen application or plugin. "origen new my_app" creates a
              new origen application workspace in "./my_app"
 interactive  Start an interactive Origen console (short-cut alias: "i"), this is just
              IRB with the 'origen' lib loaded automatically
 fetch        Automatically creates the workspace for the requested plugin and
              populates the latest version of the plugin (short-cut alias: "f")

Many commands can be run with -h (or --help) for more information.
  EOT
  exit(1)
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
origen-0.2.6 lib/origen/commands_global.rb
origen-0.2.5 lib/origen/commands_global.rb
origen-0.2.4 lib/origen/commands_global.rb
origen-0.2.3 lib/origen/commands_global.rb
origen-0.2.2 lib/origen/commands_global.rb
origen-0.2.1 lib/origen/commands_global.rb
origen-0.2.0 lib/origen/commands_global.rb
origen-0.1.3 lib/origen/commands_global.rb
origen-0.1.2 lib/origen/commands_global.rb
origen-0.1.1 lib/origen/commands_global.rb
origen-0.1.0 lib/origen/commands_global.rb
origen-0.0.9 lib/origen/commands_global.rb
origen-0.0.8 lib/origen/commands_global.rb
origen-0.0.6 lib/origen/commands_global.rb
origen-0.0.5 lib/origen/commands_global.rb
origen-0.0.4 lib/origen/commands_global.rb
origen-0.0.3 lib/origen/commands_global.rb
origen-0.0.2 lib/origen/commands_global.rb