lib/markdown_exec.rb in markdown_exec-2.5.0 vs lib/markdown_exec.rb in markdown_exec-2.6.0

- old
+ new

@@ -13,11 +13,10 @@ require 'tmpdir' require 'tty-prompt' require 'yaml' require_relative 'ansi_formatter' -# require_relative 'block_label' require_relative 'cached_nested_file_reader' require_relative 'cli' require_relative 'color_scheme' require_relative 'colorize' require_relative 'directory_searcher' @@ -92,10 +91,11 @@ # or nil if no match is found def self.extract_named_groups(str, pattern) regexp = pattern.is_a?(Regexp) ? pattern : Regexp.new(pattern) str&.match(regexp)&.named_captures&.transform_keys(&:to_sym) end + def self.extract_named_group2(match_data) match_data&.named_captures&.transform_keys(&:to_sym) end end @@ -413,38 +413,28 @@ # Main method to execute a block based on options and block_name def execute_initial_commands_and_main_loop(options, run_state) options = calculated_options.merge(options) update_options(options, over: false) # recognize commands with an opt_name, no procname - # !!b return if execute_simple_commands(options, stage: 1) - # !!b mde_vux_main_loop(opts_prepare_file_list(options)) - # !!b return unless @options[:output_saved_script_filename] - # !!b @fout.fout "script_block_name: #{run_state.script_block_name}" @fout.fout "s_save_filespec: #{run_state.saved_filespec}" end # Executes command based on the provided option keys def execute_simple_commands(options, stage: nil) # !!p stage simple_commands(options).each do |key, (cstage, proc)| if @options[key].is_a?(TrueClass) || @options[key].present? - # !!v key, 'cstage', cstage if stage && stage == cstage - # !!b proc.call return true - else - # !!b end - else - # !!b end end false end @@ -582,11 +572,11 @@ sift_regexp = Regexp.new(@options[:sift], Regexp::IGNORECASE) end files_table_rows = @options.read_saved_assets_for_history_table( asset: @options[:filename] - ) # !!v files_table_rows + ) if sift_regexp # Filter history to file names matching a pattern files_table_rows.select! { |item| sift_regexp.match(item[:file]) } end @@ -814,24 +804,18 @@ saved_script_glob, list_count) end # Reports and executes block logic def mde_vux_main_loop(files) - # !!b @options[:filename] = select_document_if_multiple(files) @options.vux_main_loop do |type, data| case type when :command_names - # !!b simple_commands(data).keys when :call_proc - # !!b - # simple_commands(data[0])[data[1]].call simple_commands(data[0])[data[1]][1].call - when :end_of_cli - # !!b execute_simple_commands(options, stage: 2) else raise end end @@ -1039,24 +1023,24 @@ list_blocks: [2, -> { list_blocks }], list_default_env: [1, -> { @fout.fout_list list_default_env }], list_default_yaml: [1, -> { @fout.fout_list list_default_yaml }], list_docs: [1, -> { @fout.fout_list opts_prepare_file_list(options) }], list_recent_output: [1, -> { - @fout.fout_list list_recent_output( - @options[:saved_stdout_folder], - @options[:saved_stdout_glob], @options[:list_count] - ) - }], + @fout.fout_list list_recent_output( + @options[:saved_stdout_folder], + @options[:saved_stdout_glob], @options[:list_count] + ) + }], list_recent_scripts: [1, -> { - @fout.fout_list list_recent_scripts( - options[:saved_script_folder], - options[:saved_script_glob], options[:list_count] - ) - }], - menu_export: [1, -> {@fout.fout menu_export }], - pwd: [1, -> {@fout.fout File.expand_path('..', __dir__) }], - run_last_script: [1, -> {run_last_script }], - tab_completions: [1, -> {@fout.fout tab_completions }] + @fout.fout_list list_recent_scripts( + options[:saved_script_folder], + options[:saved_script_glob], options[:list_count] + ) + }], + menu_export: [1, -> { @fout.fout menu_export }], + pwd: [1, -> { @fout.fout File.expand_path('..', __dir__) }], + run_last_script: [1, -> { run_last_script }], + tab_completions: [1, -> { @fout.fout tab_completions }] } end public