mirror of
https://github.com/Dummi26/mers.git
synced 2025-12-15 03:36:16 +01:00
sorted mers_lib/src/program/configs/ and added cargo features
This commit is contained in:
@@ -6,5 +6,5 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
mers_lib = { path = "../mers_lib" }
|
||||
mers_lib = { path = "../mers_lib", features = ["parse"] }
|
||||
clap = { version = "4.3.19", features = ["derive"] }
|
||||
|
||||
8
mers/src/cfg_globals.rs
Normal file
8
mers/src/cfg_globals.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
use mers_lib::{
|
||||
data::{self, Data},
|
||||
prelude_extend_config::*,
|
||||
};
|
||||
|
||||
pub fn add_general(cfg: Config) -> Config {
|
||||
cfg.add_var("mers_cli".to_string(), Data::new(data::bool::Bool(true)))
|
||||
}
|
||||
@@ -2,8 +2,11 @@ use clap::{Parser, Subcommand, ValueEnum};
|
||||
use mers_lib::prelude_compile::*;
|
||||
use std::{fmt::Display, fs, path::PathBuf};
|
||||
|
||||
mod cfg_globals;
|
||||
|
||||
#[derive(Parser)]
|
||||
struct Args {
|
||||
/// controls availability of features when compiling/running
|
||||
#[arg(long, value_enum, default_value_t = Configs::Std)]
|
||||
config: Configs,
|
||||
#[command(subcommand)]
|
||||
@@ -11,18 +14,22 @@ struct Args {
|
||||
}
|
||||
#[derive(Subcommand)]
|
||||
enum Command {
|
||||
/// runs the file
|
||||
Run { file: PathBuf },
|
||||
/// runs cli argument
|
||||
Exec { source: String },
|
||||
}
|
||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
|
||||
enum Configs {
|
||||
None,
|
||||
Base,
|
||||
Std,
|
||||
}
|
||||
impl Display for Configs {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::None => write!(f, "none"),
|
||||
Self::Base => write!(f, "base"),
|
||||
Self::Std => write!(f, "std"),
|
||||
}
|
||||
}
|
||||
@@ -30,10 +37,11 @@ impl Display for Configs {
|
||||
|
||||
fn main() {
|
||||
let args = Args::parse();
|
||||
let config = match args.config {
|
||||
let config = cfg_globals::add_general(match args.config {
|
||||
Configs::None => Config::new(),
|
||||
Configs::Base => Config::new().bundle_base(),
|
||||
Configs::Std => Config::new().bundle_std(),
|
||||
};
|
||||
});
|
||||
let (mut info1, mut info2) = config.infos();
|
||||
match args.command {
|
||||
Command::Run { file } => {
|
||||
|
||||
@@ -9,7 +9,19 @@ list := (
|
||||
8,
|
||||
9,
|
||||
);
|
||||
|
||||
total := 0
|
||||
(list item -> &total = (total, item).sum).iter
|
||||
"total: ".print
|
||||
total.println
|
||||
"sum: ".print
|
||||
list.sum.println
|
||||
iter := (list item -> { item.println 12 }).map
|
||||
"---".println
|
||||
list := iter.as_list
|
||||
list.println
|
||||
list.sum.println
|
||||
list.enumerate.as_list.println
|
||||
|
||||
"mers cli: ".print
|
||||
mers_cli.println
|
||||
|
||||
Reference in New Issue
Block a user