Class: Tuya::Command::Lib::CreateSimple

Inherits:
Tuya::Command::Lib show all
Defined in:
lib/tycli/command/lib/create_simple.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CreateSimple

Returns a new instance of CreateSimple.



19
20
21
22
# File 'lib/tycli/command/lib/create_simple.rb', line 19

def initialize(argv)
	super
	@name = argv.option('name')
end

Class Method Details

.optionsObject



9
10
11
12
13
# File 'lib/tycli/command/lib/create_simple.rb', line 9

def self.options
	[
		['--name=module_name', '--name to named your module']
	].concat(super)
end

Instance Method Details

#createModuleObject



41
42
43
44
45
46
47
48
# File 'lib/tycli/command/lib/create_simple.rb', line 41

def createModule
	result = `pod lib create #{@name} --template-url=https://code.registry.wgine.com/client-platform/pod-template-simple.git`
	result.each_line do |s|
		if s.include?("fatal")
			puts "#{s}".red
		end
	end
end

#runObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/tycli/command/lib/create_simple.rb', line 24

def run

	puts "do create a simple module named: #{@name}".green

	require 'ruby-progressbar'

	progressbar = ProgressBar.create
	15.times { progressbar.increment; sleep 2 }

	t_c = Thread.new {createModule()}

	t_c.join
	progressbar.finish

	puts "end create simple module: #{@name}".green
end

#validate!Object



15
16
17
# File 'lib/tycli/command/lib/create_simple.rb', line 15

def validate!
	help! "name need" unless @name
end