Class: VPL::Command
- Inherits:
-
CLAide::Command
- Object
- CLAide::Command
- VPL::Command
- Defined in:
- lib/vcpkg_pipeline/command.rb,
lib/vcpkg_pipeline/command/new.rb,
lib/vcpkg_pipeline/command/scan.rb,
lib/vcpkg_pipeline/command/update.rb,
lib/vcpkg_pipeline/command/publish.rb,
lib/vcpkg_pipeline/command/scan/all.rb,
lib/vcpkg_pipeline/command/scan/name.rb,
lib/vcpkg_pipeline/command/update/all.rb,
lib/vcpkg_pipeline/command/update/git.rb,
lib/vcpkg_pipeline/command/scan/branch.rb,
lib/vcpkg_pipeline/command/scan/remote.rb,
lib/vcpkg_pipeline/command/update/spec.rb,
lib/vcpkg_pipeline/command/scan/version.rb,
lib/vcpkg_pipeline/command/update/cmake.rb,
lib/vcpkg_pipeline/command/update/vcport.rb
Overview
Command
Defined Under Namespace
Classes: New, Publish, Scan, Update
Instance Attribute Summary collapse
-
#argv_extension ⇒ Object
readonly
Returns the value of attribute argv_extension.
Class Method Summary collapse
-
.ensure_not_root_or_allowed!(argv, uid = Process.uid, is_windows = Gem.win_platform?) ⇒ void
确保root用户.
-
.git_version ⇒ Gem::Version
读取Git版本号, 返回一个新的 Gem::Version 实例.
- .options ⇒ Object
- .options_extension ⇒ Object
- .options_extension_hash ⇒ Object
- .run(argv) ⇒ Object
-
.verify_minimum_git_version! ⇒ void
检查Git版本号是否低于 1.8.5.
-
.verify_xcode_license_approved! ⇒ void
检查xcode许可是否被批准.
Instance Method Summary collapse
-
#initialize(argv) ⇒ Command
constructor
A new instance of Command.
Constructor Details
#initialize(argv) ⇒ Command
Returns a new instance of Command.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/vcpkg_pipeline/command.rb', line 93 def initialize(argv) @argv_extension = {} self.class..each_key do |key| @argv_extension[key] = [] self.class..each do |option| name = option.first next unless name.include?(key) is_option = name.include? '=' if is_option option = name.gsub(/(--)(.*)(=.*)/, '\\2') value = argv.option(option, '') unless value.empty? @argv_extension[key] << name.gsub(/(--.*=)(.*)/, "\\1#{value}").gsub("#{key}-", '') end else flag = name.gsub(/(--)(.*)/, '\\2') value = argv.flag?(flag) @argv_extension[key] << name.gsub("#{key}-", '') if value end end end super end |
Instance Attribute Details
#argv_extension ⇒ Object (readonly)
Returns the value of attribute argv_extension.
120 121 122 |
# File 'lib/vcpkg_pipeline/command.rb', line 120 def argv_extension @argv_extension end |
Class Method Details
.ensure_not_root_or_allowed!(argv, uid = Process.uid, is_windows = Gem.win_platform?) ⇒ void
This method returns an undefined value.
确保root用户
50 51 52 53 |
# File 'lib/vcpkg_pipeline/command.rb', line 50 def self.ensure_not_root_or_allowed!(argv, uid = Process.uid, is_windows = Gem.win_platform?) root_allowed = argv.include?('--allow-root') help! 'You cannot run vcpkg-Pipeline as root' unless root_allowed || uid != 0 || is_windows end |
.git_version ⇒ Gem::Version
读取Git版本号, 返回一个新的 Gem::Version 实例
59 60 61 62 63 64 65 66 |
# File 'lib/vcpkg_pipeline/command.rb', line 59 def self.git_version raw_version = `git version` unless (match = raw_version.scan(/\d+\.\d+\.\d+/).first) raise "Failed to extract git version from `git --version` (#{raw_version.inspect})" end Gem::Version.new(match) end |
.options ⇒ Object
17 18 19 20 21 |
# File 'lib/vcpkg_pipeline/command.rb', line 17 def self. [ ['--help', '展示改命令的介绍面板'] ] end |
.options_extension ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/vcpkg_pipeline/command.rb', line 23 def self. = [] .each do |key, | .each do |option_extension| << [option_extension.first.gsub(/(--)(.*)/, "\\1#{key}-\\2"), option_extension.last] end end end |
.options_extension_hash ⇒ Object
33 34 35 |
# File 'lib/vcpkg_pipeline/command.rb', line 33 def self. Hash[] end |
.run(argv) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/vcpkg_pipeline/command.rb', line 37 def self.run(argv) ensure_not_root_or_allowed! argv verify_minimum_git_version! verify_xcode_license_approved! super(argv) end |
.verify_minimum_git_version! ⇒ void
This method returns an undefined value.
检查Git版本号是否低于 1.8.5
74 75 76 77 78 |
# File 'lib/vcpkg_pipeline/command.rb', line 74 def self.verify_minimum_git_version! return unless git_version < Gem::Version.new('1.8.5') raise 'You need at least git version 1.8.5 to use vcpkg-Pipeline' end |
.verify_xcode_license_approved! ⇒ void
This method returns an undefined value.
检查xcode许可是否被批准
85 86 87 88 89 90 91 |
# File 'lib/vcpkg_pipeline/command.rb', line 85 def self.verify_xcode_license_approved! return unless `/usr/bin/xcrun clang 2>&1` =~ /license/ && !$?.success? raise 'You have not agreed to the Xcode license, which ' \ 'you must do to use vcpkg. Agree to the license by running: ' \ '`xcodebuild -license`' end |