Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(compile): add Amber version, fix #181 #245

Merged
merged 9 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
201 changes: 175 additions & 26 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ colored = "2.0.0"
itertools = "0.11.0"
clap = { version = "4.4.18", features = ["derive"] }
tempfile = "3.10.1"
chrono = "0.4.38"

# test dependencies
[dev-dependencies]
Expand Down
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:", option_env!("CARGO_PKG_VERSION").unwrap(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Mte90 sorry for nitpicking, but can we remove that first space on the line with # version?

Suggested change
include_str!("header.sh"),
"# version:", option_env!("CARGO_PKG_VERSION").unwrap(),
include_str!("header.sh").trim_end(),
"\n# version:", option_env!("CARGO_PKG_VERSION").unwrap(),

"date:", Local::now().format("%Y-%m-%d %H:%M:%S").to_string().as_str()
].join(" ");
format!("{}\n{}", header, res)
}

pub fn compile(&self) -> Result<(Vec<Message>, String), Message> {
Expand Down
Loading