Skip to content

Commit

Permalink
feat(compile): add Amber version, fix amber-lang#181 (amber-lang#245)
Browse files Browse the repository at this point in the history
* feat(compile): add Amber version, fix amber-lang#181

* Update src/compiler.rs

Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>

* Update src/header.sh

Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>

* review

* fix(cargo): updated

* fix(chrono): no errors

* fix(compiler): added bash comment

* fix(compiler): empty space

---------

Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>
  • Loading branch information
Mte90 and Ph0enixKM committed Jul 3, 2024
1 parent bd01fde commit cee30f2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
30 changes: 30 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion src/compiler.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
extern crate chrono;
use chrono::prelude::*;
use crate::modules::block::Block;
use crate::rules;
use crate::translate::check_all_blocks;
Expand Down Expand Up @@ -125,7 +127,12 @@ impl AmberCompiler {
}
result.push(block.translate(&mut meta));
let res = result.join("\n");
format!("{}\n{}", include_str!("header.sh"), res)
let header = [
include_str!("header.sh"),
&("# version: ".to_owned() + option_env!("CARGO_PKG_VERSION").unwrap().to_string().as_str()),
&("# date: ".to_owned() + Local::now().format("%Y-%m-%d %H:%M:%S").to_string().as_str())
].join("\n");
format!("{}\n{}", header, res)
}

pub fn compile(&self) -> Result<(Vec<Message>, String), Message> {
Expand Down
2 changes: 1 addition & 1 deletion src/header.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
# Written in [Amber](https://amber-lang.com/)
# Written in [Amber](https://amber-lang.com/)

0 comments on commit cee30f2

Please sign in to comment.