Class: HMap::Command::Gen
- Inherits:
-
HMap::Command
- Object
- CLAide::Command
- HMap::Command
- HMap::Command::Gen
- Defined in:
- lib/hmap/command/hmap_gen.rb
Overview
hmap file gen cmd
Class Method Summary collapse
-
.options ⇒ Object
help.
Instance Method Summary collapse
-
#initialize(argv) ⇒ Gen
constructor
A new instance of Gen.
- #run ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(argv) ⇒ Gen
Returns a new instance of Gen.
19 20 21 22 23 24 25 |
# File 'lib/hmap/command/hmap_gen.rb', line 19 def initialize(argv) super project_directory = argv.option('project-directory') @clean_hmap = argv.flag?('clean-hmap', false) project_directory = Dir.pwd if project_directory.nil? @project_directory = Pathname.new(project_directory). end |
Class Method Details
.options ⇒ Object
help
35 36 37 38 39 40 |
# File 'lib/hmap/command/hmap_gen.rb', line 35 def self. [ ['--project-directory=/project/dir/', 'The path to the root of the project directory'], ['--clean-hmap', 'This option will clean up all hmap-gen setup for hmap.'] ].concat(super) end |
Instance Method Details
#run ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/hmap/command/hmap_gen.rb', line 42 def run name = 'Gen' name = 'Clean' if @clean_hmap UserInterface.puts("\n[hmapfile] #{name} start") unless @project_directory.exist? UserInterface.puts("\n[hmapfile] #{name} [ERROR] #{@project_directory} dir not exist!".red) return end HMap::MapFileWriter.new(true, @project_directory, @clean_hmap) UserInterface.puts("[hmapfile] #{name} finish") end |
#validate! ⇒ Object
27 28 29 30 31 32 |
# File 'lib/hmap/command/hmap_gen.rb', line 27 def validate! super if @project_directory.nil? help! 'error: no input project directory which to use with the `--project-directory` option.' end end |