feat: change the printing a little

This commit is contained in:
rvcas 2022-12-20 16:26:07 -05:00 committed by Lucas
parent 0b204beb58
commit 796ac28044
3 changed files with 39 additions and 47 deletions

View File

@ -36,7 +36,7 @@ where
if let Err(err) = build_result {
err.report();
println!("{}", "Summary".purple().bold());
println!("\n{}", "Summary".purple().bold());
println!(
" {} error(s), {}",
err.len(),
@ -44,7 +44,7 @@ where
);
process::exit(1);
} else {
println!("{}", "Summary".purple().bold());
println!("\n{}", "Summary".purple().bold());
println!(
" 0 error, {}",
format!("{warning_count} warning(s)").yellow(),
@ -66,10 +66,10 @@ impl telemetry::EventListener for Terminal {
} => {
println!(
"{} {} {} ({})",
"Compiling".bold().purple(),
" Compiling".bold().purple(),
name.bold(),
version,
root.to_str().unwrap_or("").bright_blue()
root.display().bright_blue()
);
}
telemetry::Event::BuildingDocumentation {
@ -79,45 +79,40 @@ impl telemetry::EventListener for Terminal {
} => {
println!(
"{} {} {} ({})",
"Generating documentation".bold().purple(),
" Generating documentation".bold().purple(),
name.bold(),
version,
root.to_str().unwrap_or("").bright_blue()
);
}
telemetry::Event::ParsingProjectFiles => {
println!("{}", "...Parsing project files".bold().purple());
}
telemetry::Event::WaitingForBuildDirLock => {
println!("{}", "...Waiting for build directory lock".bold().purple());
println!("{}", "Waiting for build directory lock ...".bold().purple());
}
telemetry::Event::TypeChecking => {
println!("{}", "...Type-checking project".bold().purple());
}
telemetry::Event::GeneratingUPLC { output_path } => {
telemetry::Event::GeneratingUPLC { output_path, name } => {
println!(
"{} in {}",
"...Generating Untyped Plutus Core".bold().purple(),
output_path.to_str().unwrap_or("").bright_blue()
"{} {} in {}",
" Generating".bold().purple(),
name.bold(),
output_path.display().bright_blue()
);
}
telemetry::Event::GeneratingDocFiles { output_path } => {
println!(
"{} in {}",
"...Generating documentation files".bold().purple(),
" Generating documentation files".bold().purple(),
output_path.to_str().unwrap_or("").bright_blue()
);
}
telemetry::Event::GeneratingUPLCFor { name, path } => {
println!(
"{} {}.{{{}}}",
"...Generating Untyped Plutus Core for".bold().purple(),
" Generating Untyped Plutus Core for".bold().purple(),
path.to_str().unwrap_or("").blue(),
name.bright_blue(),
);
}
telemetry::Event::EvaluatingFunction { results } => {
println!("{}\n", "...Evaluating function".bold().purple());
println!("{}\n", " Evaluating function ...".bold().purple());
let (max_mem, max_cpu) = find_max_execution_units(&results);
@ -126,7 +121,7 @@ impl telemetry::EventListener for Terminal {
}
}
telemetry::Event::RunningTests => {
println!("{}\n", "...Running tests".bold().purple());
println!("{} {}\n", " Testing".bold().purple(), "...".bold());
}
telemetry::Event::FinishedTests { tests } => {
let (max_mem, max_cpu) = find_max_execution_units(&tests);
@ -158,11 +153,7 @@ impl telemetry::EventListener for Terminal {
}
}
telemetry::Event::DownloadingPackage { name } => {
println!(
"{} {}",
"...Downloading".bold().purple(),
name.bright_blue()
)
println!("{} {}", " Downloading".bold().purple(), name.bold())
}
telemetry::Event::PackagesDownloaded { start, count } => {
let elapsed = format!("{:.2}s", start.elapsed().as_millis() as f32 / 1000.);
@ -172,10 +163,10 @@ impl telemetry::EventListener for Terminal {
_ => format!("{} packages in {}", count, elapsed),
};
println!("{} {}", "...Downloaded".bold().purple(), msg.bright_blue())
println!("{} {}", " Downloaded".bold().purple(), msg.bold())
}
telemetry::Event::ResolvingVersions => {
println!("{}", "...Resolving versions".bold().purple(),)
println!("{}", " Resolving versions".bold().purple(),)
}
}
}

View File

@ -20,7 +20,7 @@ use aiken_lang::{
IdGenerator,
};
use config::PackageName;
use deps::{manifest::Package, UseManifest};
use deps::UseManifest;
use miette::NamedSource;
use options::{CodeGenMode, Options};
use pallas::{
@ -166,6 +166,8 @@ where
}
pub fn compile(&mut self, options: Options) -> Result<(), Error> {
self.compile_deps()?;
self.event_listener
.handle_event(Event::StartingCompilation {
root: self.root.clone(),
@ -173,8 +175,6 @@ where
version: self.config.version.clone(),
});
self.compile_deps()?;
self.read_source_files()?;
let parsed_modules = self.parse_sources(self.config.name.clone())?;
@ -185,10 +185,6 @@ where
match options.code_gen_mode {
CodeGenMode::Build(uplc_dump) => {
self.event_listener.handle_event(Event::GeneratingUPLC {
output_path: self.output_path(),
});
let programs = self.code_gen(validators)?;
self.write_build_outputs(programs, uplc_dump)?;
@ -248,7 +244,16 @@ where
)?;
for package in manifest.packages {
self.read_package_source_files(&package)?;
let lib = self.root.join(paths::build_deps_package(&package.name));
self.event_listener
.handle_event(Event::StartingCompilation {
root: lib.clone(),
name: package.name.to_string(),
version: package.version.clone(),
});
self.read_package_source_files(&lib.join("lib"))?;
let parsed_modules = self.parse_sources(package.name)?;
@ -268,20 +273,13 @@ where
Ok(())
}
fn read_package_source_files(&mut self, package: &Package) -> Result<(), Error> {
let lib = self
.root
.join(paths::build_deps_package(&package.name))
.join("lib");
self.aiken_files(&lib, ModuleKind::Lib)?;
fn read_package_source_files(&mut self, lib: &Path) -> Result<(), Error> {
self.aiken_files(lib, ModuleKind::Lib)?;
Ok(())
}
fn parse_sources(&mut self, package_name: PackageName) -> Result<ParsedModules, Error> {
self.event_listener.handle_event(Event::ParsingProjectFiles);
let mut errors = Vec::new();
let mut parsed_modules = HashMap::with_capacity(self.sources.len());
@ -341,7 +339,6 @@ where
}
fn type_check(&mut self, mut parsed_modules: ParsedModules) -> Result<(), Error> {
self.event_listener.handle_event(Event::TypeChecking);
let processing_sequence = parsed_modules.sequence()?;
for name in processing_sequence {
@ -546,6 +543,11 @@ where
&self.module_types,
);
self.event_listener.handle_event(Event::GeneratingUPLC {
output_path: self.output_path().join(&module_name).join(&name),
name: format!("{}.{}", module_name, name),
});
let program = generator.generate(body, arguments, true);
let script = Script::new(

View File

@ -16,13 +16,12 @@ pub enum Event {
version: String,
root: PathBuf,
},
ParsingProjectFiles,
TypeChecking,
GeneratingDocFiles {
output_path: PathBuf,
},
GeneratingUPLC {
output_path: PathBuf,
name: String,
},
GeneratingUPLCFor {
name: String,