diff options
| author | Fuwn <[email protected]> | 2022-02-07 04:26:07 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-06-09 00:46:03 -0700 |
| commit | bfa483c6aa5db5c9825faded62176904d516faf7 (patch) | |
| tree | 043b73bdd939f955f2b4d1e6309c8b697d6e0544 /crates/divina/src/lib.rs | |
| download | archived-divina-bfa483c6aa5db5c9825faded62176904d516faf7.tar.xz archived-divina-bfa483c6aa5db5c9825faded62176904d516faf7.zip | |
feat(divina): pre-release :star:
Diffstat (limited to 'crates/divina/src/lib.rs')
| -rw-r--r-- | crates/divina/src/lib.rs | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/crates/divina/src/lib.rs b/crates/divina/src/lib.rs new file mode 100644 index 0000000..675efd2 --- /dev/null +++ b/crates/divina/src/lib.rs @@ -0,0 +1,75 @@ +// Copyright (C) 2022-2022 Fuwn <[email protected]> +// SPDX-License-Identifier: GPL-3.0-only + +#![deny( + warnings, + nonstandard_style, + unused, + future_incompatible, + rust_2018_idioms, + unsafe_code +)] +#![deny(clippy::all, clippy::nursery, clippy::pedantic)] +#![recursion_limit = "128"] +#![doc( + html_logo_url = "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/160/twitter/282/ribbon_1f380.png", + html_favicon_url = "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/160/twitter/282/ribbon_1f380.png" +)] + +// #[macro_use] +// extern crate log; + +#[cfg(windows)] +#[global_allocator] +static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; + +#[cfg(unix)] +#[global_allocator] +static GLOBAL: jemallocator::Jemalloc = jemallocator::Jemalloc; + +mod cli; + +use divina_compile::Compiler; +use divina_config::Config; + +#[derive(Default)] +pub struct Divina { + config: Config, + compiler: Compiler, +} +impl Divina { + #[must_use] + pub fn new() -> Self { Self::default() } + + pub fn perform(&mut self) { crate::cli::execute(self); } + + /// Prepare `self.config` for configuration + pub fn new_config(&mut self) -> &mut Self { + self.config = Config::new(); + self + } + + /// Configure `self.config` + pub fn configure_config(&mut self) { self.config.configure("Divina.lua"); } + + /// Print `self.config` + pub fn print_config(&self) { + println!("{:?}", self.config); + } + + #[must_use] + pub const fn expose_config(&self) -> &Config { &self.config } + + pub fn configure_compiler(&mut self, compiler: Compiler) { self.compiler = compiler; } +} + +/// Preliminary setup +pub fn setup() { + dotenv::dotenv().ok(); + human_panic::setup_panic!(Metadata { + version: env!("CARGO_PKG_VERSION"), + name: env!("CARGO_PKG_NAME"), + authors: env!("CARGO_PKG_AUTHORS"), + homepage: env!("CARGO_PKG_HOMEPAGE"), + }); +} |