git @ Cat's Eye Technologies Decoy / master src / decoy.lua
master

Tree @master (Download .tar.gz)

decoy.lua @masterraw · history · blame

--
-- decoy.lua
--

-- SPDX-FileCopyrightText: Copyright (c) 2023-2024 Chris Pressey, Cat's Eye Technologies.
-- This work is distributed under a 2-clause BSD license. For more information, see:
-- SPDX-License-Identifier: LicenseRef-BSD-2-Clause-X-Decoy

table = require "table"

require "decoy.model"
local Registry = require "decoy.registry"


--[[ ================== MAIN =============== ]]--

function main(arg)
    local filename  -- FIXME table of filenames
    local command = arg[1]
    local registry = Registry.new(command)
    table.remove(arg, 1)
    while #arg > 0 do
        if arg[1] == "--debug" then
            table.remove(arg, 1)
            debug_what = arg[1]
        -- elseif arg[1] == "--immediate" then
        --     table.remove(arg, 1)
        --     registry:eval_module(arg[1])  -- FIXME option to compile this
        elseif arg[1] == "--module-dir" or arg[1] == "-I" then
            table.remove(arg, 1)
            registry:set_module_path(arg[1])
        elseif arg[1] == "--implicit-prelude" or arg[1] == "--preload" or arg[1] == "-m" then
            table.remove(arg, 1)
            registry:preload_module(arg[1])
        elseif arg[1] ~= "" then
            filename = arg[1]
        end
        table.remove(arg, 1)
    end
    if not filename then
        error("No filename given")
    end
    registry:process_module_file(filename)
end

if arg ~= nil then
    main(arg)
end