GreycLab / gmic

GREYC's Magic for Image Computing: A Full-Featured Open-Source Framework for Image Processing
Other
66 stars 11 forks source link

Small improvement suggestion on quit command. #29

Closed Reptorian1125 closed 8 months ago

Reptorian1125 commented 8 months ago

There should be a default terminating echo message which is: [gmic]./ End G'MIC interpreter.. Optionally, arguments would override this message.

Now I have something like this for one of my personal user command to run Python files that aids in G'MIC scripting.

e[0] "End G'MIC interpreter."
quit

With a default print message, that can be shortened to just q or quit. I also noticed that commands that use q/quit typically don't have other codes beyond q/quit.

Here's the command code I'm using, so maybe I'm missing something here?

#@cli run_pyscript:
#@cli : Run user-defined script. If you provide no argument, then it will print description on how to use your script. If you ran into a error, run without an argument, and modify your argument to make this work.
run_pyscript:
    skip "${1=}"

    _available_variables=""
    _number_of_available_scripts=0
    script_file_info="D:\\Documents\\Python\\gmic-scripting-tools\\"

    _$0_info shift_vars_num,GMIC-Increment-Arg-Number.py,"Shift variables numbers."
    _$0_info modify_gui_vars,GUI-variable-inputs.py,"Modify GUI Variables to append numbers or to remove numbers into GUI Variables."

    if narg($1)
        if isint($1)
         id=${arg\ $1+1,$_available_variables}
        else
         id=$1
        fi

        test_input=${_script_${id}_filename}
        if !narg($test_input) error invalid_arg fi
        script_file_info.=$test_input   

        e[0] "Executing script "${_script_${id}_filename}!\n
        exec 1,"python "$script_file_info
        e[0] "Finished executing script "${_script_${id}_filename}!
    else
        e[0] "Allowed arguments: 0-"{$_number_of_available_scripts-1}"(inclusive) or "$_available_variables.
        repeat $_number_of_available_scripts {
         current_variable=${arg\ $>+1,$_available_variables}
         e[0] Arg\ $>\ :\ $current_variable\ -\ ${_script_${>}_helper}
        }
    fi

    e[0] "End G'MIC interpreter."
    quit
_run_pyscript_info:
    check "$#==3"

    if narg($_available_variables)
     _available_variables.=,$1
    else
     _available_variables.=$1
    fi

    _script_$1_filename="$2"
    _script_$1_helper="$3"

    _number_of_available_scripts+=1
dtschump commented 8 months ago

What's the problem with the current message ?

~$ gmic sp lena q
[gmic]./ Start G'MIC interpreter (v.3.3.3).
[gmic]./ Input sample image 'lena' (1 image 512x512x1x3).
[gmic]./ Quit G'MIC interpreter.
Reptorian1125 commented 8 months ago

It's not giving me that terminating message. This is what it gives me:

C:\Windows\System32>gmic run_pyscript
[gmic]./ Start G'MIC interpreter (v.3.3.3).
[gmic]./ Allowed arguments: 0-1(inclusive) or shift_vars_num,modify_gui_vars.
[gmic]./ Arg 0 : shift_vars_num - Shift variables numbers.
[gmic]./ Arg 1 : modify_gui_vars - Modify GUI Variables to append numbers or to remove numbers into GUI Variables.

So, I do have to be missing something here.

If I increase verbosity level, I get this:

[gmic]./run_pyscript/ Quit G'MIC interpreter.

Which is not exactly what I want to see because of run_pyscript part.

dtschump commented 8 months ago

It's actually intended. If you're in a command with a verbosity level of 0 , there are no reason why an output message should be displayed. To force the message, just force the verbosity level to be at least 1 before quit:

v 1 q