Class: Texico::CLI::Command::Init

Inherits:
Base
  • Object
show all
Defined in:
lib/texico/cli/command/init.rb

Instance Attribute Summary

Attributes inherited from Base

#opts, #prompt

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

inherited, #initialize, #load_config, match, priority, select

Constructor Details

This class inherits a constructor from Texico::CLI::Command::Base

Class Method Details

.match?(command) ⇒ Boolean

Returns:

  • (Boolean)


103
104
105
# File 'lib/texico/cli/command/init.rb', line 103

def match?(command)
  command == 'init'
end

Instance Method Details

#runObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/texico/cli/command/init.rb', line 7

def run
  # Show welcome text
  welcome
  # As for configuration options for this session
  config = ask_config
  # Indicate that the config was accepted
  prompt.say "#{ICON} Creating new project\n", color: :bold
  # Copy the template project
  copy_template config
  # Save the other config options to file
  ConfigFile.store config, target, opts
  
  Git.init(target, true) unless opts[:no_git]
  
  # We are done
  prompt.say "#{ICON} Done!", color: :bold
rescue TTY::Reader::InputInterrupt
  prompt.error 'Aborting'
  exit
end