Luce packages
LuceLuce BaseLuciaOS

dymokomi/luced

Source of release 0.4.1

0.4.1 / src / editor / options.luc

## Command-line policy is separate from view construction and session lifetime.
from luce_std import files
from luce_ui import ui

pub class Options:
    pub var help: bool = false
    pub var smoke: bool = false
    pub var location: str = "."
    pub var luce: str = "luce"
    pub var base: str = "luce-base"
    pub var config_directory: str = ""
    pub var luce_override: bool = false
    pub var base_override: bool = false

    pub func init(self, arguments: list[str]) -> unit!:
        var index = 0
        while index < arguments.length:
            let argument = arguments[index]
            if argument == "--help":
                self.help = true
            elif argument == "--smoke":
                self.smoke = true
            elif argument == "--luce" or argument == "--base" or argument == "--config-dir":
                index += 1
                if index >= arguments.length:
                    error(ui.invalid, argument + " needs a path")
                if argument == "--config-dir":
                    self.config_directory = arguments[index]
                    index += 1
                    continue
                let compiler = files.canonical(arguments[index])
                if argument == "--luce":
                    self.luce = compiler
                    self.luce_override = true
                else:
                    self.base = compiler
                    self.base_override = true
            elif argument.starts_with("--"):
                error(ui.invalid, "Unknown option: " + argument)
            else:
                self.location = argument
            index += 1

    pub func print_help(self):
        print("usage: luced [FILE | DIRECTORY] [--luce COMPILER] [--base COMPILER] [--config-dir DIRECTORY] [--smoke]")