Class: VPL::Command::New
Overview
Instance Attribute Summary
Attributes inherited from VPL::Command
#argv_extension
Class Method Summary
collapse
Instance Method Summary
collapse
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
30
31
32
33
34
35
36
37
38
|
# File 'lib/vcpkg_pipeline/command/new.rb', line 30
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
|
# File 'lib/vcpkg_pipeline/command/new.rb', line 24
def self.options
[
['--template-url=https://github.com/TKCMake/vcport-template.git', 'vcport模版地址']
].concat(super).concat(options_extension)
end
|
Instance Method Details
#replacements ⇒ Object
40
41
42
43
44
45
|
# File 'lib/vcpkg_pipeline/command/new.rb', line 40
def replacements
{
'PT_PORT_NAME' => @name,
'PT_USER_NAME' => Git.global_config('user.name')
}
end
|
#run ⇒ Object
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/vcpkg_pipeline/command/new.rb', line 47
def run
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
|