Skip to content

Commit beca644

Browse files
hyperpolymathclaude
andcommitted
chore: fix, Rust, lint/fmt, issues
Batch Justfile audit: standardised naming (lowercase→Justfile), fixed parse errors, removed useless build-riscv from non-Rust repos, added missing assail recipe, and fixed code quality issues. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7edd509 commit beca644

File tree

4 files changed

+76
-24
lines changed

4 files changed

+76
-24
lines changed

src/codegen/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// SPDX-License-Identifier: PMPL-1.0-or-later
22
// Copyright (c) 2026 Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>
3+
use crate::manifest::Manifest;
34
use anyhow::{Context, Result};
45
use std::fs;
5-
use std::path::Path;
6-
use crate::manifest::Manifest;
76

87
pub fn generate_all(manifest: &Manifest, output_dir: &str) -> Result<()> {
98
fs::create_dir_all(output_dir).context("Failed to create output dir")?;
10-
println!(" [stub] A2ML codegen for '{}' — implementation pending", manifest.workload.name);
9+
println!(
10+
" [stub] A2ML codegen for '{}' — implementation pending",
11+
manifest.workload.name
12+
);
1113
Ok(())
1214
}
1315

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
pub mod abi;
55
pub mod codegen;
66
pub mod manifest;
7-
pub use manifest::{load_manifest, validate, Manifest};
7+
pub use manifest::{Manifest, load_manifest, validate};
88

99
pub fn generate(manifest_path: &str, output_dir: &str) -> anyhow::Result<()> {
1010
let m = load_manifest(manifest_path)?;

src/main.rs

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,71 @@ struct Cli {
2121
#[derive(Subcommand)]
2222
enum Commands {
2323
/// Initialise a new a2mliser.toml manifest.
24-
Init { #[arg(short, long, default_value = ".")] path: String },
24+
Init {
25+
#[arg(short, long, default_value = ".")]
26+
path: String,
27+
},
2528
/// Validate a a2mliser.toml manifest.
26-
Validate { #[arg(short, long, default_value = "a2mliser.toml")] manifest: String },
29+
Validate {
30+
#[arg(short, long, default_value = "a2mliser.toml")]
31+
manifest: String,
32+
},
2733
/// Generate A2ML wrapper, Zig FFI bridge, and C headers.
2834
Generate {
29-
#[arg(short, long, default_value = "a2mliser.toml")] manifest: String,
30-
#[arg(short, long, default_value = "generated/a2mliser")] output: String,
35+
#[arg(short, long, default_value = "a2mliser.toml")]
36+
manifest: String,
37+
#[arg(short, long, default_value = "generated/a2mliser")]
38+
output: String,
3139
},
3240
/// Build the generated artifacts.
33-
Build { #[arg(short, long, default_value = "a2mliser.toml")] manifest: String, #[arg(long)] release: bool },
41+
Build {
42+
#[arg(short, long, default_value = "a2mliser.toml")]
43+
manifest: String,
44+
#[arg(long)]
45+
release: bool,
46+
},
3447
/// Run the workload.
3548
Run {
36-
#[arg(short, long, default_value = "a2mliser.toml")] manifest: String,
37-
#[arg(trailing_var_arg = true)] args: Vec<String>,
49+
#[arg(short, long, default_value = "a2mliser.toml")]
50+
manifest: String,
51+
#[arg(trailing_var_arg = true)]
52+
args: Vec<String>,
3853
},
3954
/// Show manifest information.
40-
Info { #[arg(short, long, default_value = "a2mliser.toml")] manifest: String },
55+
Info {
56+
#[arg(short, long, default_value = "a2mliser.toml")]
57+
manifest: String,
58+
},
4159
}
4260

4361
fn main() -> Result<()> {
4462
let cli = Cli::parse();
4563
match cli.command {
46-
Commands::Init { path } => { manifest::init_manifest(&path)?; }
47-
Commands::Validate { manifest } => { let m = manifest::load_manifest(&manifest)?; manifest::validate(&m)?; println!("Valid: {}", m.workload.name); }
48-
Commands::Generate { manifest, output } => { let m = manifest::load_manifest(&manifest)?; manifest::validate(&m)?; codegen::generate_all(&m, &output)?; }
49-
Commands::Build { manifest, release } => { let m = manifest::load_manifest(&manifest)?; codegen::build(&m, release)?; }
50-
Commands::Run { manifest, args } => { let m = manifest::load_manifest(&manifest)?; codegen::run(&m, &args)?; }
51-
Commands::Info { manifest } => { let m = manifest::load_manifest(&manifest)?; manifest::print_info(&m); }
64+
Commands::Init { path } => {
65+
manifest::init_manifest(&path)?;
66+
}
67+
Commands::Validate { manifest } => {
68+
let m = manifest::load_manifest(&manifest)?;
69+
manifest::validate(&m)?;
70+
println!("Valid: {}", m.workload.name);
71+
}
72+
Commands::Generate { manifest, output } => {
73+
let m = manifest::load_manifest(&manifest)?;
74+
manifest::validate(&m)?;
75+
codegen::generate_all(&m, &output)?;
76+
}
77+
Commands::Build { manifest, release } => {
78+
let m = manifest::load_manifest(&manifest)?;
79+
codegen::build(&m, release)?;
80+
}
81+
Commands::Run { manifest, args } => {
82+
let m = manifest::load_manifest(&manifest)?;
83+
codegen::run(&m, &args)?;
84+
}
85+
Commands::Info { manifest } => {
86+
let m = manifest::load_manifest(&manifest)?;
87+
manifest::print_info(&m);
88+
}
5289
}
5390
Ok(())
5491
}

src/manifest/mod.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,37 @@ pub struct Options {
3535
}
3636

3737
pub fn load_manifest(path: &str) -> Result<Manifest> {
38-
let content = std::fs::read_to_string(path).with_context(|| format!("Failed to read: {}", path))?;
38+
let content =
39+
std::fs::read_to_string(path).with_context(|| format!("Failed to read: {}", path))?;
3940
toml::from_str(&content).with_context(|| format!("Failed to parse: {}", path))
4041
}
4142

4243
pub fn validate(manifest: &Manifest) -> Result<()> {
43-
if manifest.workload.name.is_empty() { anyhow::bail!("workload.name required"); }
44-
if manifest.workload.entry.is_empty() { anyhow::bail!("workload.entry required"); }
44+
if manifest.workload.name.is_empty() {
45+
anyhow::bail!("workload.name required");
46+
}
47+
if manifest.workload.entry.is_empty() {
48+
anyhow::bail!("workload.entry required");
49+
}
4550
Ok(())
4651
}
4752

4853
pub fn init_manifest(path: &str) -> Result<()> {
4954
let p = Path::new(path).join("a2mliser.toml");
50-
if p.exists() { anyhow::bail!("a2mliser.toml already exists"); }
51-
std::fs::write(&p, "# a2mliser manifest\n[workload]\nname = \"my-workload\"\nentry = \"src/lib.rs::process\"\n\n[data]\ninput-type = \"Vec<Item>\"\noutput-type = \"Vec<Result>\"\n")?;
55+
if p.exists() {
56+
anyhow::bail!("a2mliser.toml already exists");
57+
}
58+
std::fs::write(
59+
&p,
60+
"# a2mliser manifest\n[workload]\nname = \"my-workload\"\nentry = \"src/lib.rs::process\"\n\n[data]\ninput-type = \"Vec<Item>\"\noutput-type = \"Vec<Result>\"\n",
61+
)?;
5262
println!("Created {}", p.display());
5363
Ok(())
5464
}
5565

5666
pub fn print_info(m: &Manifest) {
57-
println!("=== {} ===\nEntry: {}\nInput: {}\nOutput: {}", m.workload.name, m.workload.entry, m.data.input_type, m.data.output_type);
67+
println!(
68+
"=== {} ===\nEntry: {}\nInput: {}\nOutput: {}",
69+
m.workload.name, m.workload.entry, m.data.input_type, m.data.output_type
70+
);
5871
}

0 commit comments

Comments
 (0)