From 1af0cdcd02de9e1dcfca78ac0c8aff209def980f Mon Sep 17 00:00:00 2001 From: Fire Demon Date: Sun, 26 Jul 2020 03:23:54 -0500 Subject: [Command Tags] Fix parsing of of multi-line argument; add support for variables and templating --- app/lib/command_tag/commands/variables.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 app/lib/command_tag/commands/variables.rb (limited to 'app/lib/command_tag/commands') diff --git a/app/lib/command_tag/commands/variables.rb b/app/lib/command_tag/commands/variables.rb new file mode 100644 index 000000000..ab90ca13b --- /dev/null +++ b/app/lib/command_tag/commands/variables.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module CommandTag::Commands::Variables + def handle_set_at_start(args) + return if args.blank? + + args[0] = normalize(args[0]) + + case args.count + when 1 + @vars.delete(args[0]) + when 2 + @vars[args[0]] = [args.last] + else + @vars[args[0]] = args[1..-1] + end + end + + def do_unset_at_start(args) + args.each do |arg| + @vars.delete(normalize(arg)) + end + end +end -- cgit