From 08fa245d8c79baab3846c71a734207d3370df285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Hauspie?= <michael.hauspie@univ-lille.fr> Date: Fri, 5 Jul 2024 17:19:11 +0200 Subject: [PATCH] Fix some names following crate rename --- src/lib.rs | 13 ++++++------- src/link.rs | 2 +- src/new.rs | 21 ++++++++++----------- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 5bbfb9e..41e234e 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 fe6aad6..fcd7492 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 59344e0..3392086 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() } -- GitLab