diff options
author | Fire Demon <firedemon@creature.cafe> | 2020-07-26 03:23:54 -0500 |
---|---|---|
committer | Fire Demon <firedemon@creature.cafe> | 2020-08-30 05:45:16 -0500 |
commit | 1af0cdcd02de9e1dcfca78ac0c8aff209def980f (patch) | |
tree | 1ded845b028e3dda975230863f0087e25c61930f /app/lib/command_tag/commands/variables.rb | |
parent | 173ec3d8c765239aa54c12d8a06e7dc404a1ac9d (diff) |
[Command Tags] Fix parsing of of multi-line argument; add support for variables and templating
Diffstat (limited to 'app/lib/command_tag/commands/variables.rb')
-rw-r--r-- | app/lib/command_tag/commands/variables.rb | 24 |
1 files changed, 24 insertions, 0 deletions
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 |