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.
- #replacements ⇒ Object
- #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.
30 31 32 33 34 35 36 37 |
# File 'lib/vcpkg_pipeline/command/new.rb', line 30 def initialize(argv) @name = argv.shift_argument || '' @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 |
# 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
#replacements ⇒ Object
39 40 41 42 43 44 |
# File 'lib/vcpkg_pipeline/command/new.rb', line 39 def replacements { 'PT_PORT_NAME' => @name, 'PT_USER_NAME' => Git.global_config('user.name') } end |
#run ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/vcpkg_pipeline/command/new.rb', line 46 def run VPL.error('未输入port名称') if @name.empty? Git.clone(@template, @name, depth: 1) Dir.replace_all(@name, replacements) git = Git.open(@name) git.remote.remove git.add('.') git.commit("init #{@name}", amend: true) end |