I’m not sure if any one else would find this useful. But, here’s something I made:
#@cli gmic: gmic_file,additional_argument
#@cli : Load .gmic file and automatically run it.
#@cli : If no argument for gmic_file exists, then it will search for main.gmic or a file named gmic in current directory.
gmic:
skip "${1=}","${2=}"
if narg($1)
gmic_file=$1
else
m __$0_load:"$""=files num_of_vars:=$""#"
__$0_load ${files\ 0,.}
p=1
repeat $num_of_vars {
current_file=${files$p}
if isin(size('$current_file'),4,9)
if same('$current_file'[0,4],'main')
gmic_file=$current_file
break
fi
fi
p+=1
}
um __$0_load
if !narg($gmic_file) error no_main_file_found fi
fi
0 => $gmic_file
if same('{x}','gmic') rm. $gmic_file
else rm. i gmic:$gmic_file
fi
if narg($$__main__) __main__ ${2--1}
elif narg($$main) main ${2--1}
else echo no_main_exist" "Ignored
fi
quit
Basically, it runs main or main command automatically if found in the .gmic file. I’d probably could extend this to search for main.gmic file within a folder too and then it’ll run that. Done.
Was using this for AOC challenge to keep it separate from my actual gmic things. But, I can see it useful for testing various commands in separate folder and gmic file.