Sha256: 6dec5a98d3b51aff8b5a2d1427e0ea6125d8825fb656bb82f2dd8900e085d28c

Contents?: true

Size: 851 Bytes

Versions: 7

Compression:

Stored size: 851 Bytes

Contents

# -*- coding: UTF-8 -*-
#
# Copyright 2013 whiteleaf. All rights reserved.
#

require_relative "narou"
require_relative "command"
require_relative "helper"

module CommandLine
  def self.run(argv)
    if Helper.os_windows?
      argv.map! do |arg|
        arg.encode(Encoding::UTF_8)
      end
    end
    argv.unshift("help") if argv.empty?
    arg = argv.shift.downcase
    arg = Command::Shortcuts[arg] || arg
    arg = "help" if arg == "-h" || arg == "--help"
    arg = "version" if arg == "-v" || arg == "--version"
    unless Narou.already_init?
      unless ["help", "version", "init"].include?(arg)
        arg = "help"
      end
    end
    unless Command.get_list.include?(arg)
      puts "不明なコマンドです"
      puts
      arg = "help"
    end
    Command.get_list[arg].execute(argv)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
narou-1.1.1 lib/commandline.rb
narou-1.1.0 lib/commandline.rb
narou-1.1.0.rc2 lib/commandline.rb
narou-1.1.0.rc1 lib/commandline.rb
narou-1.0.2 lib/commandline.rb
narou-1.0.1 lib/commandline.rb
narou-1.0.0 lib/commandline.rb