mirror of
https://github.com/esp-rs/espup.git
synced 2025-09-27 12:50:54 +00:00
style: 🎨 Minor formatting
This commit is contained in:
parent
721318a526
commit
7940a32721
@ -146,6 +146,9 @@ Xtensa Rust toolchain will be installed under `<rustup_home>/toolchains/esp`.
|
||||
Usage: espup install [OPTIONS]
|
||||
|
||||
Options:
|
||||
-p, --config-path <CONFIG_PATH>
|
||||
Path to where the espup configuration file will be written to
|
||||
|
||||
-d, --default-host <DEFAULT_HOST>
|
||||
Target triple of the host
|
||||
|
||||
@ -217,6 +220,7 @@ Options:
|
||||
Usage: espup uninstall [OPTIONS]
|
||||
|
||||
Options:
|
||||
-p, --config-path <CONFIG_PATH> Path to where the espup configuration file will be written to
|
||||
-l, --log-level <LOG_LEVEL> Verbosity level of the logs [default: info] [possible values: debug, info, warn, error]
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
@ -228,6 +232,8 @@ Options:
|
||||
Usage: espup update [OPTIONS]
|
||||
|
||||
Options:
|
||||
-p, --config-path <CONFIG_PATH>
|
||||
Path to where the espup configuration file will be written to
|
||||
-d, --default-host <DEFAULT_HOST>
|
||||
Target triple of the host [possible values: x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu, x86_64-pc-windows-msvc, x86_64-pc-windows-gnu, x86_64-apple-darwin, aarch64-apple-darwin]
|
||||
-l, --log-level <LOG_LEVEL>
|
||||
|
@ -11,11 +11,6 @@ use std::{
|
||||
path::PathBuf,
|
||||
};
|
||||
|
||||
pub struct ConfigFile {
|
||||
pub path: PathBuf,
|
||||
pub config: Config,
|
||||
}
|
||||
|
||||
/// Deserialized contents of a configuration file
|
||||
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
|
||||
pub struct Config {
|
||||
@ -37,10 +32,15 @@ pub struct Config {
|
||||
pub xtensa_rust: Option<XtensaRust>,
|
||||
}
|
||||
|
||||
pub struct ConfigFile {
|
||||
pub path: PathBuf,
|
||||
pub config: Config,
|
||||
}
|
||||
|
||||
impl ConfigFile {
|
||||
/// Construcs a new config file with the given path and config
|
||||
pub fn new(config_path: &Option<PathBuf>, config: Config) -> Result<Self, Error> {
|
||||
let config_path = config_path.clone().unwrap_or(Self::get_config_path()?);
|
||||
|
||||
Ok(ConfigFile {
|
||||
path: config_path,
|
||||
config,
|
||||
@ -50,7 +50,6 @@ impl ConfigFile {
|
||||
/// Load the config from config file
|
||||
pub fn load(config_path: &Option<PathBuf>) -> Result<Self, Error> {
|
||||
let config_path = config_path.clone().unwrap_or(Self::get_config_path()?);
|
||||
|
||||
let config: Config = if let Ok(data) = read(&config_path) {
|
||||
toml::from_slice(&data).map_err(|_| Error::FailedToDeserialize)?
|
||||
} else {
|
||||
@ -58,8 +57,7 @@ impl ConfigFile {
|
||||
config_path.to_string_lossy().into_owned(),
|
||||
));
|
||||
};
|
||||
|
||||
ConfigFile::new(&Some(config_path), config)
|
||||
Self::new(&Some(config_path), config)
|
||||
}
|
||||
|
||||
/// Save the config to file
|
||||
|
20
src/main.rs
20
src/main.rs
@ -57,6 +57,9 @@ pub enum SubCommand {
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct InstallOpts {
|
||||
/// Path to where the espup configuration file will be written to.
|
||||
#[arg(short = 'p', long)]
|
||||
pub config_path: Option<PathBuf>,
|
||||
/// Target triple of the host.
|
||||
#[arg(short = 'd', long, required = false, value_parser = ["x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu", "x86_64-pc-windows-msvc", "x86_64-pc-windows-gnu" , "x86_64-apple-darwin" , "aarch64-apple-darwin"])]
|
||||
pub default_host: Option<String>,
|
||||
@ -80,9 +83,6 @@ pub struct InstallOpts {
|
||||
/// Relative or full path for the export file that will be generated. If no path is provided, the file will be generated under home directory (https://docs.rs/dirs/latest/dirs/fn.home_dir.html).
|
||||
#[arg(short = 'f', long)]
|
||||
pub export_file: Option<PathBuf>,
|
||||
/// The path to which the espup configuration file will be written to.
|
||||
#[arg(short = 'p', long)]
|
||||
pub config_path: Option<PathBuf>,
|
||||
/// Comma or space list of extra crates to install.
|
||||
#[arg(short = 'c', long, required = false, value_parser = Crate::parse_crates)]
|
||||
pub extra_crates: Option<HashSet<Crate>>,
|
||||
@ -111,6 +111,9 @@ pub struct InstallOpts {
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct UpdateOpts {
|
||||
/// Path to where the espup configuration file will be written to.
|
||||
#[arg(short = 'p', long)]
|
||||
pub config_path: Option<PathBuf>,
|
||||
/// Target triple of the host.
|
||||
#[arg(short = 'd', long, required = false, value_parser = ["x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu", "x86_64-pc-windows-msvc", "x86_64-pc-windows-gnu" , "x86_64-apple-darwin" , "aarch64-apple-darwin"])]
|
||||
pub default_host: Option<String>,
|
||||
@ -120,19 +123,16 @@ pub struct UpdateOpts {
|
||||
/// Xtensa Rust toolchain version.
|
||||
#[arg(short = 'v', long, value_parser = XtensaRust::parse_version)]
|
||||
pub toolchain_version: Option<String>,
|
||||
/// The path at which the espup configuration file can be found.
|
||||
#[arg(short = 'p', long)]
|
||||
pub config_path: Option<PathBuf>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct UninstallOpts {
|
||||
/// Path to where the espup configuration file will be written to.
|
||||
#[arg(short = 'p', long)]
|
||||
pub config_path: Option<PathBuf>,
|
||||
/// Verbosity level of the logs.
|
||||
#[arg(short = 'l', long, default_value = "info", value_parser = ["debug", "info", "warn", "error"])]
|
||||
pub log_level: String,
|
||||
/// The path at which the espup configuration file can be found.
|
||||
#[arg(short = 'p', long)]
|
||||
pub config_path: Option<PathBuf>,
|
||||
}
|
||||
|
||||
/// Installs the Rust for ESP chips environment
|
||||
@ -278,7 +278,7 @@ async fn install(args: InstallOpts) -> Result<()> {
|
||||
};
|
||||
let config_file = ConfigFile::new(&args.config_path, config)?;
|
||||
info!(
|
||||
"{} Saving configuration file at {:?}",
|
||||
"{} Storing configuration file at '{:?}'",
|
||||
emoji::WRENCH,
|
||||
config_file.path
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user