lib/brief/cli/write.rb in brief-1.12.1 vs lib/brief/cli/write.rb in brief-1.12.2
- old
+ new
@@ -6,18 +6,22 @@
# We could potential query the available model classes we are aware of
# and determine which CLI arguments those model classes may ask for.
c.action do |args, options|
options.default(root: Pathname(Brief.pwd))
briefcase = Brief.case = Brief::Briefcase.new(root: options.root)
- schema_map = briefcase.schema_map()
-
type_alias = args.first
- model_class = schema_map.fetch(type_alias) do
- raise "Unknown model type: #{ type_alias }. Available types are: #{ schema_map.keys.join(',') }"
+ model_class = briefcase.model_classes.find {|c| c.type_alias == type_alias }
+
+ if !model_class.nil?
+ content = ask_editor model_class.writing_prompt()
+ else
+ model_class = briefcase.schema_map.fetch(type_alias, nil)
+ content = ask_editor(model_class.example)
end
- content = ask_editor model_class.writing_prompt()
+ raise "Inavlid model class. Run the schema command to see what is available." if model_class.nil?
+
file = ask("Enter a filename")
if file.to_s.length == 0
rand_token = rand(36**36).to_s(36).slice(0,3)