diff --git a/src/lib.rs b/src/lib.rs index 5bbfb9e0bc1c4600c9aa74e33d0d61b5ea48e909..41e234e8be3a156d95dd03f5e0d0cc6a7004cca7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,22 +12,21 @@ use clap::{Parser, Subcommand}; #[command(version, about, long_about = None)] pub struct Opts { #[command(subcommand)] - command: PipToolSubcommand, + command: TrollSubcommand, } #[derive(Subcommand, Debug)] -pub enum PipToolSubcommand { - /// Generate a new pip partition project +pub enum TrollSubcommand { + /// Generate a new project New(new::Opts), - /// Link elf files together and generate a binary blob ready to be - /// flashed/loaded + /// Link elf files together and generate a Troll binary blob ready to be flashed/loaded Link(link::Opts), } pub fn execute(opts: Opts) -> Result<()> { match opts.command { - PipToolSubcommand::New(opts) => new::generate(opts)?, - PipToolSubcommand::Link(opts) => link::link(opts)?, + TrollSubcommand::New(opts) => new::generate(opts)?, + TrollSubcommand::Link(opts) => link::link(opts)?, } Ok(()) } diff --git a/src/link.rs b/src/link.rs index fe6aad652de5599d66a430feba7924e5ad30dfd5..fcd7492941e45ce4f56a7344b218d104540a4a3c 100644 --- a/src/link.rs +++ b/src/link.rs @@ -62,7 +62,7 @@ pub struct Opts { /// Dump the binary content of the given sections to the output file. /// /// It returns the number of bytes writen -fn dump_sections<'s, T: Write>( +fn dump_sections<T: Write>( elf: &elf::ElfBytes<AnyEndian>, section_names: &[&str], output: &mut T, diff --git a/src/new.rs b/src/new.rs index 59344e088f40184797ec9bb1a0729860f395a409..33920868db6909fe2815d7909ec198bd324c620b 100644 --- a/src/new.rs +++ b/src/new.rs @@ -8,23 +8,22 @@ use std::path::PathBuf; #[derive(Parser, Debug)] pub struct Opts { - /// The path where to generate your crate - crate_path: PathBuf, + /// The path where to generate your project + project_path: PathBuf, /// The name of the generated project. If omitted, deduced from - /// the crate_path parameter + /// the PROJECT_PATH parameter #[arg(long, short)] - crate_name: Option<String>, + project_name: Option<String>, } -const PIP_MPU_TEMPLATE_PATH: &str = - "https://gitlab.univ-lille.fr/2xs/pip/troll-template.git"; +const PIP_MPU_TEMPLATE_PATH: &str = "https://gitlab.univ-lille.fr/2xs/pip/troll-template.git"; pub fn generate(opts: Opts) -> Result<()> { - let crate_name = match opts.crate_name { + let project_name = match opts.project_name { Some(name) => name, None => opts - .crate_path + .project_path .file_name() .unwrap() .to_os_string() @@ -33,10 +32,10 @@ pub fn generate(opts: Opts) -> Result<()> { }; let scaffold_opts = cargo_scaffold::Opts::builder(PIP_MPU_TEMPLATE_PATH) - .parameters(vec![format!("crate_name={}", crate_name)]) + .parameters(vec![format!("project_name={}", project_name)]) .force(true) - .project_name(crate_name) - .target_dir(opts.crate_path); + .project_name(project_name) + .target_dir(opts.project_path); cargo_scaffold::ScaffoldDescription::new(scaffold_opts)?.scaffold() }