# Serialize `model` to a file next to `file_name`
fun write_model_to_file
do
+ if not sys.opt_save_model.value then return
+
# Write the model to file next to the Nit module
var model_path = file_name.strip_extension + ".jwrapper.bin"
var model_stream = model_path.to_path.open_wo
# Option to _not_ generate properties (static or from classes)
var opt_no_properties = new OptionBool("Do not wrap properties, only classes and basic services", "-n", "--no-properties")
+
+ # Should the model be serialized to a file?
+ var opt_save_model = new OptionBool("Save the model next to the generated Nit module", "-s", "--save-model")
end
redef class String
var opt_regex = new OptionString("Regex pattern to filter classes in Jar archives", "-r")
var opt_help = new OptionBool("Show this help message", "-h", "--help")
-opts.add_option(opt_output, opt_unknown, opt_extern_class_prefix, opt_libs, opt_regex, opt_cast_objects, opt_arrays, opt_load_models, opt_no_properties, opt_verbose, opt_help)
+opts.add_option(opt_output, opt_unknown, opt_extern_class_prefix, opt_libs, opt_regex, opt_cast_objects, opt_arrays, opt_save_model, opt_load_models, opt_no_properties, opt_verbose, opt_help)
opts.parse args
if opts.errors.not_empty or opts.rest.is_empty or opt_help.value then