elf: will start using clap to parse assembler arguments for CLI
I am tired af for some reason
This commit is contained in:
@@ -13,6 +13,7 @@ name = "assembler"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.5.40", features = ["derive"] }
|
||||
common = { path = "../common" }
|
||||
num_cpus = "1.17.0"
|
||||
threadpool = "1.8.1"
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
use clap::{Parser, ValueEnum};
|
||||
|
||||
#[derive(Debug, Parser, Default)]
|
||||
pub struct Args {
|
||||
/// The output format to assemble to. Currently just ELF or a flat binary.
|
||||
#[arg(value_enum)]
|
||||
output_format: Option<OutputFormat>,
|
||||
/// Whether the relocatable object files should be statically linked into a single executable or library.
|
||||
link: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, ValueEnum, Default)]
|
||||
/// The executable format the output should take.
|
||||
pub enum OutputFormat {
|
||||
/// An ELF file.
|
||||
#[default]
|
||||
Elf,
|
||||
/// A flat binary file.
|
||||
Flat,
|
||||
}
|
||||
@@ -12,6 +12,7 @@
|
||||
clippy::match_wildcard_for_single_variants
|
||||
)]
|
||||
|
||||
pub mod args;
|
||||
pub mod assembler;
|
||||
pub mod brainf;
|
||||
pub mod tooling;
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
use assembler::{brainf, prelude::*};
|
||||
use clap::Parser;
|
||||
use std::{fs, io::Write, path::PathBuf};
|
||||
|
||||
fn main() {
|
||||
// Parse command line arguments
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
|
||||
let _clap_args = assembler::args::Args::parse();
|
||||
|
||||
if args.len() == 2 && args[1] == "init" {
|
||||
project::tool_libcreate();
|
||||
std::process::exit(0);
|
||||
|
||||
Reference in New Issue
Block a user