godotengine / emacs-gdscript-mode

An Emacs package to get GDScript support and syntax highlighting.
GNU General Public License v3.0
316 stars 36 forks source link

Question: how to run-script with arguments? #114

Closed katzecase closed 2 years ago

katzecase commented 2 years ago

Hello! Is there a way to run-script with arguments? I am trying to improve my workflow in emacs with Gut, especially run from the command line.

I was using gut to test all file or gut mytest to test specific test file in bash, with this shell script:

gut () {
    if [ -z $1 ]
        then
        godot -s $PWD/addons/gut/gut_cmdln.gd --path $PWD -gdir=res://test -ginclude_subdirs -glog=1 -gexit
    else
        godot -s $PWD/addons/gut/gut_cmdln.gd --path $PWD -gdir=res://test -ginclude_subdirs -gselect=test_$1.gd -glog=1 -gexit
    fi
}

Now with gdscript-mode I can run-current-scene of the test scene provide by Gut, and use hydra to run-last-command. But then I can't specify the test, and I'll need to manually close the Godot debug window. I also tried to use run-from-history from hydra to pass in arguments with the script, but doesn't seems to work.

Thanks in advanced!

NathanLovato commented 2 years ago

You probably need to write a new function. I think that you can call gdscript-godot--run-command with your arguments in lisp.

I don´t think we included a way to manually input arguments when running the command, but anyway you wouldn't want to type arguments every time. So it's best for you to write a lisp function and give it some keybindings.

Calling the function above should give you the same output window you've seen in emacs so far.

Otherwise, you can use the shell in emacs to run your bash script like usual. I use vterm to bring up shell windows and write commands directly in my shell.