Sha256: deca5dbd97b780344e83f49917838525d4dfba0c8f8966b460cafcbefc84697f

Contents?: true

Size: 852 Bytes

Versions: 3

Compression:

Stored size: 852 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)
      error "不明なコマンドです"
      puts
      arg = "help"
    end
    Command.get_list[arg].execute(argv)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
narou-1.2.0 lib/commandline.rb
narou-1.1.2.1 lib/commandline.rb
narou-1.1.2 lib/commandline.rb