/*
    This file is part of GNU APL, a free implementation of the
    ISO/IEC Standard 13751, "Programming Language APL, Extended"

    Copyright © 2008-2020  Dr. Jürgen Sauermann

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/


// definition of APL commands and the functions that implement them
// keep it sorted so that longer prefixes come first !!!

//      command       , implementation                                , arguments                   , tab expansion hint
//----------------------------------------------------------------------------------------------------------------------
cmd_def( ")CHECK"     , cmd_CHECK(out, arg);                          , "[BRIEF]"                   , EH_NO_PARAM)
cmd_def( ")CLEAR"     , Workspace::clear_WS(out, false);              , ""                          , EH_NO_PARAM)
cmd_def( ")CONTINUE"  , cmd_CONTINUE(out);                            , ""                          , EH_NO_PARAM)
cmd_def( ")COPY_ONCE" , Command::cmd_COPY_ONCE(out, args);            , "[[lib] wsname]"            , EH_oLIB_WSNAME)
cmd_def( ")COPY"      , Command::cmd_COPY(out, args, false);          , "[lib] wsname [object ...]" , EH_oLIB_WSNAME)
cmd_def( ")DROP"      , cmd_DROP(out, args);                          , "[lib] wsname"              , EH_oLIB_WSNAME)
cmd_def( ")DUMP-HTML" , Command::cmd_DUMP(out, args, true,  false);   , "[[lib] wsname]"            , EH_oLIB_WSNAME)
cmd_def( ")DUMPV"     , Command::cmd_DUMP(out, args, false, false);   , "[[lib] wsname]"            , EH_oLIB_WSNAME)
cmd_def( ")DUMP"      , Command::cmd_DUMP(out, args, false, true);    , "[[lib] wsname]"            , EH_oLIB_WSNAME)
cmd_def( ")ERASE"     , cmd_ERASE(out, args);                         , "symbol ..."                , EH_SYMBOLS)
cmd_def( ")FNS"       , Workspace::list(out, LIST_FUNS, arg);         , "[from-to]"                 , EH_oFROM_oTO)
cmd_def( ")HELP"      , cmd_HELP(out, arg);                           , "[primitive]"               , EH_PRIMITIVE)
cmd_def( ")HIST"      , cmd_HISTORY(out, arg);                        , "[CLEAR]"                   , EH_oCLEAR)
cmd_def( ")HOST"      , cmd_HOST(out, arg);                           , "command ..."               , EH_HOSTCMD)
cmd_def( ")IN"        , cmd_IN(out, args, false);                     , "filename [object ...]"     , EH_FILENAME)
cmd_def( ")LIBS"      , cmd_LIBS(out, args);                          , "[[lib] path]"              , EH_oLIB_oPATH)
cmd_def( ")LIB"       , cmd_LIB1(out, args);                          , "[lib|path] [from-to]"      , EH_DIR_OR_LIB)
cmd_def( ")LOAD"      , Command::cmd_LOAD(out, args, line, false);    , "[lib] wsname"              , EH_oLIB_WSNAME)
cmd_def( ")MORE"      , cmd_MORE(out, args);                          , "[AUTO [ON|OFF]]"           , EH_oAUTO)
cmd_def( ")NMS"       , Workspace::list(out, LIST_NAMES, arg);        , "[from-to]"                 , EH_oFROM_oTO)
cmd_def( ")OFF"       , cmd_OFF(arg.atoi());                          , "[exit_code]"               , EH_COUNT)
cmd_def( ")OPS"       , Workspace::list(out, LIST_OPERS, arg);        , "[from-to]"                 , EH_oFROM_oTO)
cmd_def( ")OUT"       , cmd_OUT(out, args);                           , "filename [object ...]"     , EH_FILENAME)
cmd_def( ")PCOPY"     , Command::cmd_COPY(out, args, true);           , "[lib] wsname [object ...]" , EH_oLIB_WSNAME)
cmd_def( ")PIN"       , cmd_IN(out, args, true);                      , "filename [object ...]"     , EH_FILENAME)
cmd_def( ")QLOAD"     , Command::cmd_LOAD(out, args, line, true);     , "[lib] wsname"              , EH_oLIB_WSNAME)
cmd_def( ")RESET"     , Workspace::clear_SI(out);                     , ""                          , EH_NO_PARAM)
cmd_def( ")SAVE"      , Command::cmd_SAVE(out, args);                 , "[[lib] wsname]"            , EH_oLIB_WSNAME)
cmd_def( ")SIC"       , Workspace::clear_SI(out);                     , ""                          , EH_NO_PARAM)
cmd_def( ")SINL"      , Workspace::list_SI(out, SIM_SINL);            , ""                          , EH_NO_PARAM)
cmd_def( ")SIS"       , Workspace::list_SI(out, SIM_SIS);             , ""                          , EH_NO_PARAM)
cmd_def( ")SI"        , Workspace::list_SI(out, SIM_SI);              , ""                          , EH_NO_PARAM)
cmd_def( ")SYMBOLS"   , Workspace::list(out, LIST_NONE, arg);         , "[count]"                   , EH_COUNT)
cmd_def( ")VALUES"    , Value::list_all(out, false);                  , ""                          , EH_NO_PARAM)
cmd_def( ")VARS"      , Workspace::list(out, LIST_VARS, arg);         , "[from-to]"                 , EH_oFROM_oTO)
cmd_def( ")WSID"      , Workspace::wsid(out, arg, LIB_WSNAME, false); , "[wsname]"                  , EH_oWSNAME)

cmd_def( "]BOXING"    , cmd_BOXING(out, arg);                         , "[OFF|2|3|4|7|8|9]"         , EH_BOXING)
cmd_def( "]COLOR"     , cmd_XTERM(out, arg)                           , "[ON|OFF]"                  , EH_oON_OFF)
cmd_def( "]DOXY"      , cmd_DOXY(out, args);                          , "[path]"                    , EH_oPATH)
cmd_def( "]EXPECT"    , IO_Files::expect_apl_errors(arg);             , "error_count"               , EH_COUNT)
cmd_def( "]HELP"      , cmd_HELP(out, arg);                           , "[primitive]"               , EH_NO_PARAM)
cmd_def( "]KEYB"      , cmd_KEYB(out);                                , ""                          , EH_NO_PARAM)
cmd_def( "]LIB"       , cmd_LIB2(out, args);                          , "[lib|path] [from-to]"      , EH_DIR_OR_LIB)
cmd_def( "]LOG"       , cmd_LOG(out, arg);                            , "[facility|ON|OFF] ..."     , EH_LOG_NUM)
cmd_def( "]NEXTFILE"  , cmd_NEXTFILE(out, args);                      , "[cond ...]"                , EH_CONFIG)
cmd_def( "]OPTIM"     , cmd_OPTIM(out, arg);                          , "[CLEAR]"                   , EH_PRIMITIVE)
cmd_def( "]PUSHFILE"  , cmd_PUSHFILE();                               , ""                          , EH_NO_PARAM)
cmd_def( "]OWNERS"    , Value::list_all(out, true);                   , ""                          , EH_NO_PARAM)
cmd_def( "]PSTAT"     , cmd_PSTAT(out, arg);                          , "[CLEAR|SAVE]"              , EH_oCLEAR_SAVE)
cmd_def( "]SIS"       , Workspace::list_SI(out, SIM_SIS_dbg);         , ""                          , EH_NO_PARAM)
cmd_def( "]SI"        , Workspace::list_SI(out, SIM_SI_dbg);          , ""                          , EH_NO_PARAM)
cmd_def( "]SVARS"     , Svar_DB::print(out);                          , ""                          , EH_NO_PARAM)
cmd_def( "]SYMBOL"    , Workspace::get_symbol_table()
                                  .list_symbol(out, arg);             , "symbol"                    , EH_SYMNAME)
cmd_def( "]USERCMD"   , cmd_USERCMD(out, arg, args);                  , "[ ]ucmd APL_fun [mode]"    , EH_UCOMMAND)
cmd_def( "        "   , {}                                            , ""                          , EH_NO_PARAM)
cmd_def( "        "   , {}                                            , "| ]ucmd { ... }"           , EH_NO_PARAM)
cmd_def( "        "   , {}                                            , ""                          , EH_NO_PARAM)
cmd_def( "        "   , {}                                            , "| REMOVE ]ucmd"            , EH_NO_PARAM)
cmd_def( "        "   , {}                                            , ""                          , EH_NO_PARAM)
cmd_def( "        "   , {}                                            , "| REMOVE-ALL"              , EH_NO_PARAM)
cmd_def( "        "   , {}                                            , ""                          , EH_NO_PARAM)
cmd_def( "        "   , {}                                            , "]"                         , EH_NO_PARAM)
cmd_def( "]XTERM"     , cmd_XTERM(out, arg)                           , "[ON|OFF]"                  , EH_oON_OFF)

#undef cmd_def
