66#
77# Configuration via environment and config file.
88#
9- # @see "/bin/.mqlcrc" for an example
9+ # @see "/bin/.mqlcrc.dist " for an example
1010# @see https://www.metatrader5.com/en/metaeditor/help/beginning/integration_ide#compiler
1111#
1212#
1313# TODO:
1414# - colored output
1515# - implement download tracker
16- # - option --rc/--norc
16+ # - option --rc/--no-rc
1717# - option --clean
1818# - option --syntax
1919# - option --info
@@ -50,21 +50,21 @@ Usage: mqlc [options] [--] SOURCES...
5050 mqlc [options] /compile:(FILE|DIR)... [/include:DIR]... [/log[:FILE]]
5151
5252Arguments:
53- SOURCES One or more MQL files or source directories to compile. Supports wildcards.
54-
55- Options:
56- -h --help This screen.
57- /compile:FILE Source file to compile. Doesn't support wildcards.
58- /compile:DIR Source directory to compile. Recompiles new and modified sources (not in subdirectories).
59- /include:DIR Include directory for the following sources (default: "<data-dir>/MQL4" or "<data-dir>/MQL5").
60- /log Writes output to "<source-file.log>" (default: no logfile on success, logfile on errors/warnings).
61- /log:FILE Writes output to the specified logfile.
62- -v=VERSION MQL version of the following MQL4 sources: either "mql40" or "mql45". May appear multiple times.
63- -v= --version= Empty version argument: auto-detect the version of the following MQL4 sources (default).
64- -s --syntax Syntax check only, no compilation.
65- -w --warn2error Treat compiler warnings as errors, affects the exit status.
66- --[no] color Enforce or disable colored output (default: auto).
67- --rc=FILE --norc Use the specified configuration file, or no file at all (default: see configuration section).
53+ SOURCES One or more MQL files or source directories to compile. Supports wildcards.
54+
55+ Options:
56+ -h, --help This screen.
57+ /compile:FILE Source file to compile. Doesn't support wildcards.
58+ /compile:DIR Source directory to compile. Recompiles new and modified sources (not in subdirectories).
59+ /include:DIR Include directory for the following sources (default: "<data-dir>/MQL4" or "<data-dir>/MQL5").
60+ /log Writes output to "<source-file.log>" (default: no logfile on success, logfile on errors/warnings).
61+ /log:FILE Writes output to the specified logfile.
62+ -v=VERSION MQL version of the following MQL4 sources: either "mql40" or "mql45". Can appear multiple times.
63+ -v=, --version= Empty version argument: auto-detect the version of the following MQL4 sources (default).
64+ -s, --syntax Syntax check only, no compilation.
65+ -w, --warn2error Treat compiler warnings as errors, affects the exit status.
66+ --color, --no-color Enforce or disable colored output (default: auto).
67+ --rc=FILE, --no-rc Use the specified configuration file, or no file at all (default: see configuration section).
6868
6969The script exits with 0 (success) or the number of errors of the last failing compilation.
7070
@@ -625,7 +625,7 @@ function fail() {
625625#
626626# @param $@ - any number of arguments
627627#
628- function stderr () {
628+ function stderr() {
629629 echo " $@ " >&2
630630}
631631
@@ -979,12 +979,12 @@ while (("$#")); do
979979 continue ;;
980980
981981 -v|--version)
982- syntaxError " missing version argument: $1 " ;;
982+ syntaxError " Missing version argument: $1 " ;;
983983
984984 -v=* |--version=* )
985985 version=" ${1#* =} "
986986 version=" ${version,,} "
987- [[ -n " $version " && " $version " != mql4[05] ]] && syntaxError " invalid version argument in \" $1 \" (expecting \" mql40\" or \" mql45\" )"
987+ [[ -n " $version " && " $version " != mql4[05] ]] && syntaxError " Invalid version argument in \" $1 \" (expecting \" mql40\" or \" mql45\" )"
988988 if (( firstVersion < 0 )) ; then
989989 for i in " ${! srcFileVersions[@]} " ; do
990990 srcFileVersions[i]=" $version " # the first --version affects previous sources if no more sources follow
@@ -994,13 +994,13 @@ while (("$#")); do
994994 shift ; continue ;;
995995
996996 -* )
997- syntaxError " unrecognized option \" $1 \" (use the -- delimiter if source arguments start with a hyphen)" ;;
997+ syntaxError " Unrecognized option \" $1 \" (use the -- delimiter if source arguments start with a hyphen)" ;;
998998
999999 /inc|/include|/inc[=:]* |/include[=:]* )
10001000 [[ " $1 " == /include* ]] && include=" ${1: 9} " || include=" ${1: 5} "
10011001 include=" $( sanitizeName " $include " ) "
1002- [[ -z " $include " ]] && syntaxError " missing argument: $1 "
1003- [[ -d " $include " ]] || syntaxError " include directory not found: \" $include \" "
1002+ [[ -z " $include " ]] && syntaxError " Missing argument: $1 "
1003+ [[ -d " $include " ]] || syntaxError " Include directory not found: \" $include \" "
10041004 if (( firstInclude < 0 )) ; then
10051005 for i in " ${! srcFileIncludes[@]} " ; do
10061006 srcFileIncludes[i]=" $include " # the first /include affects previous sources if no more sources follow
@@ -1010,18 +1010,18 @@ while (("$#")); do
10101010 shift ; continue ;;
10111011
10121012 /log|/log[=:]* )
1013- [[ " $log " -eq 1 ]] && syntaxError " multiple /log options"
1013+ [[ " $log " -eq 1 ]] && syntaxError " Multiple /log options"
10141014 log=1
10151015 if [[ ${# 1} -gt 4 ]]; then
10161016 customLog=" $( sanitizeName " ${1: 5} " ) "
1017- [[ -z " $customLog " ]] && syntaxError " missing argument: $1 "
1017+ [[ -z " $customLog " ]] && syntaxError " Missing argument: $1 "
10181018 customLog=" $( cygpath -w " $customLog " ) "
10191019 fi
10201020 shift ; continue ;;
10211021
10221022 /compile[=:]* )
10231023 srcArg=" $( sanitizeName " ${1: 9} " ) "
1024- [[ -z " $srcArg " ]] && syntaxError " missing argument: $1 " ;;
1024+ [[ -z " $srcArg " ]] && syntaxError " Missing argument: $1 " ;;
10251025 # processing continues after the case block
10261026 esac
10271027 fi
@@ -1038,14 +1038,14 @@ while (("$#")); do
10381038 done < <( find " $srcArg " -maxdepth 1 -type f -iname ' *.mq[45]' )
10391039 elif [[ -f " $srcArg " ]]; then
10401040 ext=" $( fileExtension " $srcArg " ) "
1041- [[ " ${ext,,} " != mq[45] ]] && syntaxError " cannot compile file \" $srcArg \" "
1041+ [[ " ${ext,,} " != mq[45] ]] && syntaxError " Cannot compile file \" $srcArg \" "
10421042 srcFileNames+=(" $srcArg " )
10431043 srcFileVersions+=(" ${version:- } " )
10441044 srcFileIncludes+=(" ${include:- } " )
10451045 else
10461046 srcArg=" $1 "
10471047 [[ " $srcArg " =~ ^[[:space:]]* $ ]] && srcArg=" \" $srcArg \" "
1048- syntaxError " file or directory not found: $srcArg "
1048+ syntaxError " File or directory not found: $srcArg "
10491049 fi
10501050
10511051 if (( firstVersion > 0 )) ; then
0 commit comments