Class: RubyYacht::Runner::CreateNewProject
- Defined in:
- lib/ruby_yacht/runner/create_new_project.rb
Overview
This command provides help information about other commands.
Instance Attribute Summary collapse
-
#directory ⇒ Object
The directory where we should place the config.
-
#project ⇒ Object
The project that we are creating.
Class Method Summary collapse
-
.command ⇒ Object
The name of the command.
-
.description ⇒ Object
The short description of the command.
Instance Method Summary collapse
-
#option_parser ⇒ Object
This method gets the command-line options for the command.
-
#parse_positional_arguments(arguments) ⇒ Object
This method extracts arguments from the command line.
-
#run ⇒ Object
This method runs the logic for the command.
Methods inherited from Command
#backtick, #default_project, #docker, #docker_machine, #get_machine_info, #log, #project_named, #projects, short_script_name, #system
Instance Attribute Details
#directory ⇒ Object
The directory where we should place the config.
18 19 20 |
# File 'lib/ruby_yacht/runner/create_new_project.rb', line 18 def directory @directory end |
#project ⇒ Object
The project that we are creating.
15 16 17 |
# File 'lib/ruby_yacht/runner/create_new_project.rb', line 15 def project @project end |
Class Method Details
.command ⇒ Object
The name of the command.
7 |
# File 'lib/ruby_yacht/runner/create_new_project.rb', line 7 def self.command; 'new'; end |
.description ⇒ Object
The short description of the command.
10 11 12 |
# File 'lib/ruby_yacht/runner/create_new_project.rb', line 10 def self.description 'Create a new ruby-yacht project' end |
Instance Method Details
#option_parser ⇒ Object
This method gets the command-line options for the command.
21 22 23 24 25 |
# File 'lib/ruby_yacht/runner/create_new_project.rb', line 21 def option_parser OptionParser.new do || . = "Usage: #{Command.short_script_name} new [PROJECT] [DIRECTORY]\n\n#{self.class.description}" end end |
#parse_positional_arguments(arguments) ⇒ Object
This method extracts arguments from the command line.
Parameters
- arguments: Array The command line arguments.
32 33 34 35 |
# File 'lib/ruby_yacht/runner/create_new_project.rb', line 32 def parse_positional_arguments(arguments) self.project = arguments.shift self.directory = arguments.shift end |
#run ⇒ Object
This method runs the logic for the command.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/ruby_yacht/runner/create_new_project.rb', line 38 def run if project.nil? log 'You must provide a project' log "Run #{Command.short_script_name} help new for more information" return false end if directory.nil? log 'You must provide a directory' log "Run #{Command.short_script_name} help new for more information" return false end FileUtils.mkdir_p(directory) File.open(File.join(directory, 'run.rb'), 'w') do |file| write_config_file(file) end log "Your project has been created in #{directory}/run.rb." log "You can go to #{directory} and run `ruby run.rb build` to create your docker containers." log "Your initial app will be created in the #{project} directory." true end |