Skip to content

Commit

Permalink
Remove emojis (#376)
Browse files Browse the repository at this point in the history
* style: Remove emojis

* docs: Update changelog
  • Loading branch information
SergioGasquez authored Oct 18, 2023
1 parent 80205ed commit 75f8932
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 138 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed
- Update GCC version to 13.2 (#373)
- Update logging format and log messages (#375, #376)

### Removed

Expand Down
16 changes: 6 additions & 10 deletions src/env.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Environment variables set up and export file support.

use crate::{emoji, error::Error};
use crate::error::Error;
use directories::BaseDirs;
use log::info;
#[cfg(windows)]
Expand Down Expand Up @@ -71,7 +71,7 @@ pub fn get_export_file(export_file: Option<PathBuf>) -> Result<PathBuf, Error> {

/// Creates the export file with the necessary environment variables.
pub fn create_export_file(export_file: &PathBuf, exports: &[String]) -> Result<(), Error> {
info!("{} Creating export file", emoji::WRENCH);
info!("Creating export file");
let mut file = File::create(export_file)?;
for e in exports.iter() {
#[cfg(windows)]
Expand All @@ -89,25 +89,21 @@ pub fn export_environment(export_file: &Path) -> Result<(), Error> {
if cfg!(windows) {
set_environment_variable("PATH", &env::var("PATH").unwrap())?;
warn!(
"{} Your environments variables have been updated! Shell may need to be restarted for changes to be effective",
emoji::INFO
"Your environments variables have been updated! Shell may need to be restarted for changes to be effective"
);
warn!(
"{} A file was created at '{}' showing the injected environment variables",
emoji::INFO,
"A file was created at '{}' showing the injected environment variables",
export_file.display()
);
}
#[cfg(unix)]
if cfg!(unix) {
println!(
"\n\t{} To get started, you need to set up some environment variables by running: '. {}'",
emoji::INFO,
"\n\tTo get started, you need to set up some environment variables by running: '. {}'",
export_file.display()
);
println!(
"\t{} This step must be done every time you open a new terminal.\n\t See other methods for setting the environment in https://esp-rs.github.io/book/installation/riscv-and-xtensa.html#3-set-up-the-environment-variables",
emoji::WARN
"\tThis step must be done every time you open a new terminal.\n\t See other methods for setting the environment in https://esp-rs.github.io/book/installation/riscv-and-xtensa.html#3-set-up-the-environment-variables",
);
}
Ok(())
Expand Down
45 changes: 15 additions & 30 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,87 +1,72 @@
//! Custom error implementations.

use crate::emoji;

#[derive(Debug, miette::Diagnostic, thiserror::Error)]
pub enum Error {
#[diagnostic(code(espup::toolchain::create_directory))]
#[error("{} Creating directory '{0}' failed", emoji::ERROR)]
#[error("Creating directory '{0}' failed")]
CreateDirectory(String),

#[diagnostic(code(espup::toolchain::rust::query_github))]
#[error("{} Failed to query GitHub API", emoji::ERROR)]
#[error("Failed to query GitHub API")]
GithubQuery,

#[diagnostic(code(espup::toolchain::rust::install_riscv_target))]
#[error(
"{} Failed to Install RISC-V targets for '{0}' toolchain",
emoji::ERROR
)]
#[error("Failed to Install RISC-V targets for '{0}' toolchain")]
InstallRiscvTarget(String),

#[diagnostic(code(espup::ivalid_destination))]
#[error(
"{} Invalid export file destination: '{0}'. Please, use an absolute or releative path (including the file and its extension)",
emoji::ERROR
)]
"Invalid export file destination: '{0}'. Please, use an absolute or releative path (including the file and its extension)")]
InvalidDestination(String),

#[diagnostic(code(espup::toolchain::rust::invalid_version))]
#[error(
"{} Invalid toolchain version '{0}'. Verify that the format is correct: '<major>.<minor>.<patch>.<subpatch>' or '<major>.<minor>.<patch>', and that the release exists in https://github.com/esp-rs/rust-build/releases",
emoji::ERROR
)]
"Invalid toolchain version '{0}'. Verify that the format is correct: '<major>.<minor>.<patch>.<subpatch>' or '<major>.<minor>.<patch>', and that the release exists in https://github.com/esp-rs/rust-build/releases")]
InvalidVersion(String),

#[error(transparent)]
IoError(#[from] std::io::Error),

#[diagnostic(code(espup::toolchain::rust::missing_rust))]
#[error(
"{} Rust is not installed. Please, install Rust via rustup: https://rustup.rs/",
emoji::ERROR
)]
#[error("Rust is not installed. Please, install Rust via rustup: https://rustup.rs/")]
MissingRust,

#[diagnostic(code(espup::remove_directory))]
#[error("{} Failed to remove '{0}'", emoji::ERROR)]
#[error("Failed to remove '{0}'")]
RemoveDirectory(String),

#[error(transparent)]
RewquestError(#[from] reqwest::Error),

#[diagnostic(code(espup::toolchain::rust::rustup_detection_error))]
#[error("{} Error detecting rustup: {0}", emoji::ERROR)]
#[error("Error detecting rustup: {0}")]
RustupDetection(String),

#[diagnostic(code(espup::toolchain::rust::serialize_json))]
#[error("{} Failed to serialize json from string", emoji::ERROR)]
#[error("Failed to serialize json from string")]
SerializeJson,

#[diagnostic(code(espup::toolchain::rust::uninstall_riscv_target))]
#[error("{} Failed to uninstall RISC-V target", emoji::ERROR)]
#[error("Failed to uninstall RISC-V target")]
UninstallRiscvTarget,

#[diagnostic(code(espup::toolchain::unsupported_file_extension))]
#[error("{} Unsuported file extension: '{0}'", emoji::ERROR)]
#[error("Unsuported file extension: '{0}'")]
UnsuportedFileExtension(String),

#[diagnostic(code(espup::host_triple::unsupported_host_triple))]
#[error("{} Host triple '{0}' is not supported", emoji::ERROR)]
#[error("Host triple '{0}' is not supported")]
UnsupportedHostTriple(String),

#[diagnostic(code(espup::targets::unsupported_target))]
#[error("{} Target '{0}' is not supported", emoji::ERROR)]
#[error("Target '{0}' is not supported")]
UnsupportedTarget(String),

#[diagnostic(code(espup::toolchain::rust::rust))]
#[error("{} Failed to install 'rust' component of Xtensa Rust", emoji::ERROR)]
#[error("Failed to install 'rust' component of Xtensa Rust")]
XtensaRust,

#[diagnostic(code(espup::toolchain::rust::rust_src))]
#[error(
"{} Failed to install 'rust-src' component of Xtensa Rust",
emoji::ERROR
)]
#[error("Failed to install 'rust-src' component of Xtensa Rust")]
XtensaRustSrc,
}
7 changes: 1 addition & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub mod cli;
pub mod emoji;
pub mod env;
pub mod error;
pub mod host_triple;
Expand Down Expand Up @@ -27,7 +26,6 @@ pub mod logging {
}

pub mod update {
use crate::emoji;
use log::warn;
use std::time::Duration;
use update_informer::{registry, Check};
Expand All @@ -40,10 +38,7 @@ pub mod update {
update_informer::new(registry::Crates, name, version).interval(Duration::ZERO);

if let Some(version) = informer.check_version().ok().flatten() {
warn!(
"{} A new version of {name} ('{version}') is available",
emoji::WARN
);
warn!("A new version of {name} ('{version}') is available");
}
}
}
16 changes: 5 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use clap::{CommandFactory, Parser};
use espup::env::set_environment_variable;
use espup::{
cli::{CompletionsOpts, InstallOpts, UninstallOpts},
emoji,
error::Error,
logging::initialize_logger,
toolchain::{
Expand Down Expand Up @@ -41,11 +40,7 @@ async fn completions(args: CompletionsOpts) -> Result<()> {
initialize_logger(&args.log_level);
check_for_update(env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));

info!(
"{} Generating completions for {} shell",
emoji::DISC,
args.shell
);
info!("Generating completions for {} shell", args.shell);

clap_complete::generate(
args.shell,
Expand All @@ -54,7 +49,7 @@ async fn completions(args: CompletionsOpts) -> Result<()> {
&mut std::io::stdout(),
);

info!("{} Completions successfully generated!", emoji::CHECK);
info!("Completions successfully generated!");

Ok(())
}
Expand All @@ -73,16 +68,15 @@ async fn uninstall(args: UninstallOpts) -> Result<()> {
initialize_logger(&args.log_level);
check_for_update(env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));

info!("{} Uninstalling the Espressif Rust ecosystem", emoji::DISC);
info!("Uninstalling the Espressif Rust ecosystem");
let install_path = get_rustup_home().join("toolchains").join(args.name);

Llvm::uninstall(&install_path)?;

uninstall_gcc_toolchains(&install_path)?;

info!(
"{} Deleting the Xtensa Rust toolchain located in '{}'",
emoji::DISC,
"Deleting the Xtensa Rust toolchain located in '{}'",
&install_path.display()
);
remove_dir_all(&install_path)
Expand All @@ -91,7 +85,7 @@ async fn uninstall(args: UninstallOpts) -> Result<()> {
#[cfg(windows)]
set_environment_variable("PATH", &env::var("PATH").unwrap())?;

info!("{} Uninstallation successfully completed!", emoji::CHECK);
info!("Uninstallation successfully completed!");
Ok(())
}

Expand Down
6 changes: 3 additions & 3 deletions src/targets.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! ESP32 chip variants support.

use crate::{emoji, error::Error};
use crate::error::Error;
use log::debug;
use miette::Result;
use std::{collections::HashSet, str::FromStr};
Expand Down Expand Up @@ -39,7 +39,7 @@ impl Target {

/// Returns a vector of Chips from a comma or space separated string.
pub fn parse_targets(targets_str: &str) -> Result<HashSet<Target>, Error> {
debug!("{} Parsing targets: {}", emoji::DEBUG, targets_str);
debug!("Parsing targets: {}", targets_str);

let targets_str = targets_str.to_lowercase();
let targets_str = targets_str.trim();
Expand All @@ -57,7 +57,7 @@ pub fn parse_targets(targets_str: &str) -> Result<HashSet<Target>, Error> {
targets
};

debug!("{} Parsed targets: {:?}", emoji::DEBUG, targets);
debug!("Parsed targets: {:?}", targets);
Ok(targets)
}

Expand Down
8 changes: 3 additions & 5 deletions src/toolchain/gcc.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! GCC Toolchain source and installation tools.

use crate::{
emoji,
error::Error,
host_triple::HostTriple,
toolchain::{download_file, Installable},
Expand Down Expand Up @@ -53,11 +52,10 @@ impl Gcc {
impl Installable for Gcc {
async fn install(&self) -> Result<Vec<String>, Error> {
let extension = get_artifact_extension(&self.host_triple);
debug!("{} GCC path: {}", emoji::DEBUG, self.path.display());
debug!("GCC path: {}", self.path.display());
if self.path.exists() {
warn!(
"{} Previous installation of GCC exists in: '{}'. Reusing this installation",
emoji::WARN,
"Previous installation of GCC exists in: '{}'. Reusing this installation",
&self.path.display()
);
} else {
Expand Down Expand Up @@ -128,7 +126,7 @@ fn get_artifact_extension(host_triple: &HostTriple) -> &str {

/// Checks if the toolchain is pressent, if present uninstalls it.
pub fn uninstall_gcc_toolchains(toolchain_path: &Path) -> Result<(), Error> {
info!("{} Uninstalling GCC", emoji::WRENCH);
info!("Uninstalling GCC");

let gcc_toolchains = vec![XTENSA_GCC, RISCV_GCC];

Expand Down
8 changes: 3 additions & 5 deletions src/toolchain/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#[cfg(windows)]
use crate::env::{delete_environment_variable, set_environment_variable};
use crate::{
emoji,
error::Error,
host_triple::HostTriple,
toolchain::{download_file, rust::RE_EXTENDED_SEMANTIC_VERSION, Installable},
Expand Down Expand Up @@ -119,7 +118,7 @@ impl Llvm {

/// Uninstall LLVM toolchain.
pub fn uninstall(toolchain_path: &Path) -> Result<(), Error> {
info!("{} Uninstalling Xtensa LLVM", emoji::WRENCH);
info!("Uninstalling Xtensa LLVM");
let llvm_path = toolchain_path.join(CLANG_NAME);
if llvm_path.exists() {
#[cfg(windows)]
Expand Down Expand Up @@ -151,12 +150,11 @@ impl Installable for Llvm {

if Path::new(&self.path).exists() {
warn!(
"{} Previous installation of LLVM exists in: '{}'. Reusing this installation",
emoji::WARN,
"Previous installation of LLVM exists in: '{}'. Reusing this installation",
self.path.to_str().unwrap()
);
} else {
info!("{} Installing Xtensa LLVM", emoji::WRENCH);
info!("Installing Xtensa LLVM");
download_file(
self.repository_url.clone(),
"idf_tool_xtensa_elf_clang.tar.xz",
Expand Down
Loading

0 comments on commit 75f8932

Please sign in to comment.