Crate libmask

Crate libmask 

Source
Expand description

§libmask

libmask aims to simplify Haxe development by providing version management capabilities.

Haxe, unlike other toolchains, lacks unified compatibility between versions; even minor versions may create new non-backwards compatible syntax. To work around this, complex systems need to be set up to actually use good version management, and they are typically tedious to use. This means that there may be issues in the long term, such as slower work and much more trouble configuring multi-version setups.

libmask aims to provide an interface to allow programs to perform transparent version management. The de facto standard in programs that use this library is mask-hx, which is its parent project, but libmask is usable by anyone.

§Description

libmask grants an interface to handle Haxe versions through filesystem management and simple configuration files.

§Haxe Versions

Haxe versions are provided through a simple HaxeVersion tuple struct. The structure provides an implementation focused on the access of the actual version directory.

§Configuration

libmask uses a very simple configuration file format that contains only a version number string. For example, below would be a valid configuration, since it only contains a version number:

4.2.5

Newlines are always stripped when reading files.

Configuration files are usable through the Config tuple struct, which wraps a HaxeVersion tuple struct as data and provides configuration file reading, writing, and parsing.

§Program Execution

All programs under a valid Haxe version directory can be executed using the haxe_exec method in the root module. This method modifies the environment the child process is in, ensuring that further child processes will also make use of the programs, avoiding complications with system packages.

§Usage

The following is a sample of working with libmask:

use libmask::*;

// The first argument in the configuration constructor can accept a
// custom configuration file path by wrapping it in an Option.
let config: Config = match Config::new(None) {
    Ok(data) => data,
    // Although it's not recommended to construct configurations
    // without performing any reading, the nature of tuple structs
    // allows this kind of construction.
    Err(_) => Config(HaxeVersion("4.2.5".into()))
};

match haxe_exec(vec!["--help".into()], config, Some("haxe".into())) {
    Ok(_) => println!("Successfully ran Haxe compiler"),
    Err(e) => println!("{}", e),
}

Structs§

Config
A basic representation of a libmask configuration.
HaxeVersion
Basic structure that details Haxe versions.

Functions§

create_patched_cmd
Attempts to create a Command that has its PATH prepended with a Config’s version directory.
haxe_exec
Executes a specified program under a version directory.