Two different error commands for G'MIC?

While making my own reference command using downloaded .html files via website so that I can have a offline way to load up reference document with G’MIC application alone, I noticed this:

C:\Windows\System32>gmic reference inp,sub,math
[gmic]./ Start G'MIC interpreter (v.3.3.3).
[gmic] *** Error in ./ (file 'C:\Users\User\user.gmic', line #7953) *** invalid_argument $1

And it doesn’t load up the help documentation within CLI header. That’s pretty much it.

I’m wondering if there should be two different error command. One in case it has nothing to do with user’s arguments, and the other in case it definitely has to do with arguments. Like error_args could load up the CLI header?

Here’s another case where CLI header doesn’t load up:

C:\Windows\System32>gmic +pal cuta
[gmic]./ Start G'MIC interpreter (v.3.3.3).
[gmic] *** Error in ./+pal/+_pal/*repeat/ *** Unknown command or filename ''; did you mean '%'?

Current command if you can find a fix:

#@cli reference: document_name
#@cli : Displays G'MIC scripting documentation directly on the browser.
#@cli :
#@cli : 'document_name' can be { 0=inp=input | 1=sub=substitution | 2=math=math_parser=expr=expression=mathematical_expression }
#@cli :
#@cli : 'document_name' can be a integer or a string corresponding to their document name.
check "$#"



repeat $# {
    if isnum($c_arg)
        if !isint($c_arg) error "invalid_argument $"$p fi
        if !narg($c_arg) error "invalid_argument $"$p fi
    set[-1] $c_arg,$c_arg
    if im!=-1 break fi

discard. -1

header="C:\\Users\\User\\Documents\\G'MIC\\Reference Documentation\\G'MIC - GREYC's Magic for Image Computing_ A Full-Featured Open-Source Framework for Image Processing - "

repeat h {
    wait 50
    if $p==2 file_end="Mathematical Expressions"
    elif $p==1 file_end="Substitution Rules"
    else file_end="Input Data"
    e[0] "Loading \""$file_end"\" document onto browser!"
    exec 1,$header$file_end

e[0] "Quit G'MIC interpreter." q

Perhaps I misunderstand your effort, but you can generate copies of the G’MIC Reference web pages (all of them!) on your local machine without taking too many special steps. gmic_stdlib.gmic has utility commands to generate both the reference and tutorial pages. The following procedure is Linux-centric and assumes file systems that support symbolic linking.

  1. The local machine should have forks of the gmic and gmic-community git repositories.
    a. For bleeding edge, git switch to the develop branch in the gmic repository.
    b. Remember to git pull origin develop to get the current commits.
    c. For official release versions of the web pages (not bleeding edge), be on the master branch instead and git pull origin master.

  2. In your home directory, you need to create a work directory with a few symbolic links to directories in the gmic and gmic-community repositories. Here’s my typical shell session:

Point your favorite browser toward index.html in the reference directory and read your local version of Reference preamble.

Spelunk around line 11200 in gmic_stdlib.gmic for the implementation of update_reference_html. parse_cli does the heavy lifting of translating #@cli comments to HTML. Doesn’t seem to be too much of a lift to adapt this to read the various include files for one’s own, personal reference pages. Maybe that’s already in place and I’m not paying attention.

Hope this helps some.

1 Like

I think that’s a better way of grabbing html file into the computer, but my efforts is more about displaying html file directly from the command-line interface or another way to directly display the information provided by the reference documentation. That’s why I created my own command with the use of exec to load html after I execute my own command, just so that I can display them from CLI instead of having to open a browser to do that or finding the file on computer and double-clicking.

1 Like


G’MIC is very optimized about finding custom commands — has to do it all the time. parse_cli can do the lookup on any custom command known to the interpreter and can be asked to output in other than ascii.

It is a bit rigid regarding where cascading style sheets are (two steps up from the working directory). parse_cli expects its calling command to do that set up for it — it is not designed to be called directly. But it seems very, very close to what you are looking for: "help that outputs in HTML instead of ascii. No?