Class: GeneSystem::Commands::CreateManifest
- Inherits:
-
Object
- Object
- GeneSystem::Commands::CreateManifest
- Defined in:
- lib/gene_system/commands/create_manifest.rb
Overview
Create manifest command
Constant Summary collapse
- DEFAULT_MANIFEST_NAME =
Default name of gene system manifest
'manifest.json'.freeze
Instance Method Summary collapse
-
#initialize(options) ⇒ CreateManifest
constructor
A new instance of CreateManifest.
-
#run ⇒ Object
Creates a new, blank manifest with at the specified destination with the specified name.
Constructor Details
#initialize(options) ⇒ CreateManifest
Returns a new instance of CreateManifest.
10 11 12 13 |
# File 'lib/gene_system/commands/create_manifest.rb', line 10 def initialize() @options = @prompt = TTY::Prompt.new end |
Instance Method Details
#run ⇒ Object
Creates a new, blank manifest with at the specified destination with the specified name.
If the options are not provided the user will be prompted for the manifest name and location.
If the output location is not a directory then a RuntimeError will be raised.
When successfully rendered a success message will be printed to STDOUT.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/gene_system/commands/create_manifest.rb', line 28 def run manifest_name = @options.name manifest_name ||= @prompt.ask( 'Please enter the name of the manifest', default: DEFAULT_MANIFEST_NAME ) output_location = @options.out output_location ||= @prompt.ask( 'Please specify output location', default: Dir.pwd ) raise 'output location must be a folder' unless File.directory?(output_location) GeneSystem::Generators.render_empty_manifest( manifest_name, output_location ) puts "✔ Manifest successfully created in #{output_location}" end |