Class: Sumcli::Commands::New

Inherits:
Sumcli::Command show all
Defined in:
lib/sumcli/commands/new.rb

Instance Method Summary collapse

Methods inherited from Sumcli::Command

#command, #cursor, #editor, #exec_exist?, #generator, #pager, #platform, #prompt, #screen, #which

Constructor Details

#initialize(name, options) ⇒ New

Returns a new instance of New.



8
9
10
11
# File 'lib/sumcli/commands/new.rb', line 8

def initialize(name, options)
  @name = name
  @options = options
end

Instance Method Details

#execute(input: $stdin, output: $stdout) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/sumcli/commands/new.rb', line 13

def execute(input: $stdin, output: $stdout)
  output.puts "OK"

  unless @name.nil? or File.directory?(@name)
    directory = File.expand_path('../../templates/new/app', __FILE__)
    return generator.copy_directory(directory, @name)
  end

  output.puts "Directory #{@name} already exists."
end