about summary refs log tree commit diff
path: root/app/lib/command_tag
diff options
context:
space:
mode:
Diffstat (limited to 'app/lib/command_tag')
-rw-r--r--app/lib/command_tag/command/footer_tools.rb33
-rw-r--r--app/lib/command_tag/processor.rb2
2 files changed, 34 insertions, 1 deletions
diff --git a/app/lib/command_tag/command/footer_tools.rb b/app/lib/command_tag/command/footer_tools.rb
new file mode 100644
index 000000000..c0f347303
--- /dev/null
+++ b/app/lib/command_tag/command/footer_tools.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+module CommandTag::Command::FooterTools
+  def handle_footertools_startup
+    @status.footer = var('persist:footer:default')[0]
+  end
+
+  def handle_footer_before_save(args)
+    return if args.blank?
+
+    name = normalize(args.shift)
+    return (@status.footer = nil) if read_falsy_from(name)
+
+    var_name = "persist:footer:#{name}"
+    return @status.footer = var(var_name)[0] if args.blank?
+    return @vars.delete(var_name) if read_falsy_from(normalize(args[0]))
+
+    if name == 'default'
+      @vars['persist:footer:default'] = @vars[var_name].presence || [args.join(' ')]
+    elsif %w(default DEFAULT).include?(args[0])
+      @vars['persist:footer:default'] = var(var_name)
+    else
+      @vars[var_name] = [args.join(' ')]
+    end
+
+    @status.footer = var(var_name)[0]
+  end
+
+  alias handle_signature_before_save    handle_footer_before_save
+  alias handle_sign_before_save         handle_footer_before_save
+  alias handle_sig_before_save          handle_footer_before_save
+  alias handle_am_before_save           handle_footer_before_save
+  alias handle_are_before_save          handle_footer_before_save
+end
\ No newline at end of file
diff --git a/app/lib/command_tag/processor.rb b/app/lib/command_tag/processor.rb
index f96bddca0..01c06faf3 100644
--- a/app/lib/command_tag/processor.rb
+++ b/app/lib/command_tag/processor.rb
@@ -84,7 +84,7 @@ class CommandTag::Processor
 
     execute_statements(:at_end)
     all_handlers!(:shutdown)
-  rescue Failure => e
+  rescue StandardError => e
     @status.update(published: false)
     @status.destroy
     raise