Class: VPL::Command::New
- Inherits:
-
VPL::Command
- Object
- CLAide::Command
- VPL::Command
- VPL::Command::New
- Defined in:
- lib/vcpkg_pipeline/command/new.rb
Overview
VPL::Command::New
Instance Attribute Summary
Attributes inherited from VPL::Command
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ New
constructor
A new instance of New.
- #run ⇒ Object
Methods inherited from VPL::Command
ensure_not_root_or_allowed!, git_version, options_extension, options_extension_hash, run, verify_minimum_git_version!, verify_xcode_license_approved!
Constructor Details
#initialize(argv) ⇒ New
Returns a new instance of New.
31 32 33 34 35 36 37 38 |
# File 'lib/vcpkg_pipeline/command/new.rb', line 31 def initialize(argv) @name = argv.shift_argument VPL.error('未输入port名称') if @name.empty? @template = argv.option('template-url', '').split(',').first @template ||= 'https://github.com/TKCMake/vcport-template.git' super end |
Class Method Details
.options ⇒ Object
24 25 26 27 28 29 |
# File 'lib/vcpkg_pipeline/command/new.rb', line 24 def self. [ '--template-url=https://github.com/TKCMake/vcport-template.git', 'vcport模版地址' ].concat(super).concat() end |
Instance Method Details
#run ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/vcpkg_pipeline/command/new.rb', line 40 def run Git.clone(@template, @name, depth: 1) replacements = { 'PT_PORT_NAME' => @name, 'PT_USER_NAME' => Git.global_config('user.name') } Dir.replace_all(@name, replacements) git = Git.open(@name) git.remote.remove git.add('.') git.commit("init #{@name}", amend: true) end |