Skip to content

Commit

Permalink
Join all arguments into a single string if the command accepts a sing…
Browse files Browse the repository at this point in the history
…le string (no need for quotation marks)
  • Loading branch information
limbonaut committed Sep 11, 2024
1 parent 932cba7 commit 77a010e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion limbo_console.gd
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,14 @@ func _parse_argv(p_argv: PackedStringArray, p_callable: Callable, r_args: Array)
var max_args: int = method_info.args.size()
var num_with_defaults: int = method_info.default_args.size()
var required_args: int = max_args - num_with_defaults

# Join all arguments into a single string if the callable accepts a single string argument.
if max_args == 1 and method_info.args[0].type == TYPE_STRING:
var a: String = " ".join(p_argv.slice(1))
if a.left(1) == '"' and a.right(1) == '"':
a = a.trim_prefix('"').trim_suffix('"')
r_args.append(a)
return true
if num_args < required_args:
error("Missing arguments.")
return false
Expand All @@ -568,7 +576,9 @@ func _parse_argv(p_argv: PackedStringArray, p_callable: Callable, r_args: Array)
var expected_type: int = method_info.args[i - 1].type

if expected_type == TYPE_STRING:
r_args[i - 1] = a.trim_prefix('"').trim_suffix('"')
if a.left(1) == '"' and a.right(1) == '"':
a = a.trim_prefix('"').trim_suffix('"')
r_args[i - 1] = a
elif a.begins_with('(') and a.ends_with(')'):
var vec = _parse_vector_arg(a)
if vec != null:
Expand Down

0 comments on commit 77a010e

Please sign in to comment.