Class: KStarter::Commands::NewProject

Inherits:
Command
  • Object
show all
Defined in:
lib/k_starter/commands/project/new_project.rb

Overview

Command Name goes here

Instance Attribute Summary collapse

Attributes inherited from Command

#escape_pressed

Instance Method Summary collapse

Methods inherited from Command

#ask_questions, #display_exiting_projects, #select_project

Methods included from TtyHelpers

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

Constructor Details

#initialize(form_type:, form_variant:) ⇒ NewProject

Returns a new instance of NewProject.



10
11
12
13
14
15
# File 'lib/k_starter/commands/project/new_project.rb', line 10

def initialize(form_type:, form_variant:)
  @form_type = form_type
  @form_variant = form_variant

  super()
end

Instance Attribute Details

#form_typeObject (readonly)

Returns the value of attribute form_type.



7
8
9
# File 'lib/k_starter/commands/project/new_project.rb', line 7

def form_type
  @form_type
end

#form_variantObject (readonly)

Returns the value of attribute form_variant.



8
9
10
# File 'lib/k_starter/commands/project/new_project.rb', line 8

def form_variant
  @form_variant
end

Instance Method Details

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



17
18
19
20
21
22
23
24
25
# File 'lib/k_starter/commands/project/new_project.rb', line 17

def execute(input: $stdin, output: $stdout)
  questions = ask_questions(form_type, form_variant)
  questions.ask_questions

  puts JSON.pretty_generate(questions.to_h)
  App.project.save_project(questions)
rescue KStarter::EscapePressed
  prompt.warn 'Exiting without saving'
end