import-modules

Crates.ioimport-modules
lib.rsimport-modules
version1.0.0
sourcesrc
created_at2023-06-18 02:40:59.441921
updated_at2023-08-09 04:43:08.099448
descriptionimport-modules is a library based on require-all
homepagehttps://github.com/FlamesX-128/import-modules#import-modules
repositoryhttps://github.com/FlamesX-128/import-modules
max_upload_size
id893227
size17,586
Flames (FlamesX-128)

documentation

README

import-modules

Description

import-modules is a library based on require-all

Examples

This is based on the import-modules test directory.

Inter Process and Post Process

Intermediary processes allow you to manipulate how the modules are processed.

Input

use import_macro::import;

// The {} is replaced by the module.
let functions = import!({
    "directory": "tests/math/",
    "inter_process": "math::{}::handler,",
    "post_process": "vec![{}]"
});

Output

let functions = vec![
    math::add::handler,
    math::sub::handler,
];

Module

Similar to intermediate process, this imports it by default as Rust module.

Input

use import_macro::import;

import!({
    "directory": "tests",
});

Output

mod math;

Authors

Change log

1.0.0 - The new import

All macros have been eliminated. Instead, use the new import macro, which employs JSON configuration. The following valid configuration is available:

struct Config {
    /// The directory where the modules are located.
    pub directory: String,

    /// Recursive search for modules.
    pub recursive: bool,

    /// Intermediary processes allow you to manipulate how the modules are processed.
    /// Intermediary processes replaces {} with the module.
    pub inter_process: Option<String>,

    /// Post processes allow you to manipulate how the modules are processed.
    /// Post_process replaces the with the module.
    pub post_process: Option<String>,

    /// Similar to intermediate process, this imports it by default as a public Rust module.
    pub public_module: Option<bool>,

    /// Similar to intermediate process, this imports it by default as a Rust module.
    ///
    /// Default if you don't use inter_process: true
    /// Default if you use public_module: true
    pub module: Option<bool>,

    /// Exclude files from the module list.
    ///
    /// Default: ["lib.rs", "main.rs", "mod.rs"]
    pub exclude_files: Vec<Regex>,

    /// Exclude directories from the module list.
    ///
    /// Default: [".git", ".github", "lib", "src" "tests", "target"]
    /// Note: Only if ends by directory separator.
    pub exclude_dirs: Vec<Regex>,

    /// Include files from the module list.
    pub include_files: Vec<Regex>,

    /// Include directories from the module list.
    pub include_dirs: Vec<Regex>,
}

License

This project is licensed under the MIT license.

Commit count: 31

cargo fmt