Top Level Namespace

Defined Under Namespace

Modules: Magellan

Instance Method Summary collapse

Instance Method Details

#cli(args, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/magellan/cli/script.rb', line 5

def cli(args, options = {})
  args = Shellwords.split(args) if args.is_a?(String)
  args << "-V" if ARGV.include?("-V")
  $PROGRAM_NAME, backup = "magellan-cli", $PROGRAM_NAME
  puts "[CLI] `#{$PROGRAM_NAME} #{args.join(' ')}`"
  begin
    Magellan::Cli::Command.start(args) do |e|
      exit(1) unless e.message =~ options[:allow]
    end
  ensure
    $PROGRAM_NAME = backup
  end
end