Godot-GDShell icon indicating copy to clipboard operation
Godot-GDShell copied to clipboard

Add optional type casting to command arguments

Open CollCaz opened this issue 1 year ago • 7 comments

I think it should be possible to type cast arguments, for example:

example: Running [ command int(3) ] in the cosole:

func _main(argv: Array, data) -> Dictionary:
    output(argv[1]) # outputs 3
    output(typeof(argv[1])) # outputs 4 (meaning string)
    output(typed_argv[1])) #outputs 3
    output(typeof(typed_argv[1])) #outputs 2 (meaning int)

This may or may not be better if implemented in the base GDShellCommand resource rather than per command, idk.

would store the first argument in argv[] as int, the second as a float and the last one as a string.

This would be very useful when creating commands that call a function or a signal, so you could pass in arguments to that function or signal in the expected type.

This could be done with regex and, GDScript's built in type casting.

I plan to implement this feature, as I am also working on the emit_signal command from issue #15 and, also plan on creating a command that calls functions from nodes.

CollCaz avatar Aug 11 '23 15:08 CollCaz