Fix styling and naming

This commit is contained in:
collin 2020-08-21 19:53:56 -07:00
parent 55fdb24bfb
commit 5ab4d62a2b
6 changed files with 50 additions and 35 deletions

View File

@ -21,12 +21,7 @@
// leo add -a author -p package_name
//
use crate::{
cli::CLI,
cli_types::*,
config::*,
errors::{AddError::*, CLIError::AddError},
};
use crate::{cli::CLI, cli_types::*, config::*, errors::AddError::*};
use leo_package::{
imports::{ImportsDirectory, IMPORTS_DIRECTORY_NAME},
root::Manifest,
@ -90,7 +85,7 @@ impl CLI for AddCommand {
fn output(options: Self::Options) -> Result<Self::Output, crate::errors::CLIError> {
// Begin "Adding" context for console logging
let span = tracing::span!(tracing::Level::INFO, "Adding");
let enter = span.enter();
let _enter = span.enter();
let token = read_token()?;
@ -115,13 +110,11 @@ impl CLI for AddCommand {
Ok(response) => (response, package_name),
//Cannot connect to the server
Err(_error) => {
return Err(AddError(ConnectionUnavailable(
"Could not connect to the package manager".into(),
)));
return Err(ConnectionUnavailable("Could not connect to the package manager".into()).into());
}
}
}
_ => return Err(AddError(MissingAuthorOrPackageName)),
_ => return Err(MissingAuthorOrPackageName.into()),
};
let mut path = current_dir()?;
@ -135,13 +128,13 @@ impl CLI for AddCommand {
let mut zip_arhive = match zip::ZipArchive::new(reader) {
Ok(zip) => zip,
Err(error) => return Err(AddError(ZipError(error.to_string().into()))),
Err(error) => return Err(ZipError(error.to_string().into()).into()),
};
for i in 0..zip_arhive.len() {
let file = match zip_arhive.by_index(i) {
Ok(file) => file,
Err(error) => return Err(AddError(ZipError(error.to_string().into()))),
Err(error) => return Err(ZipError(error.to_string().into()).into()),
};
let file_name = file.name();
@ -160,7 +153,7 @@ impl CLI for AddCommand {
}
}
tracing::info!("Successfully added a package");
tracing::info!("Successfully added a package\n");
Ok(())
}
}

View File

@ -117,6 +117,8 @@ impl CLI for InitCommand {
}
}
tracing::info!("Successfully initialized package \"{}\"\n", package_name);
Ok(())
}
}

View File

@ -116,6 +116,8 @@ impl CLI for NewCommand {
MainFile::new(&package_name).write_to(&path)?;
}
tracing::info!("Successfully initialized package \"{}\"\n", package_name);
Ok(())
}
}

View File

@ -49,7 +49,9 @@ impl CLI for RunCommand {
// Begin "Verifying" context for console logging
let span = tracing::span!(tracing::Level::INFO, "Verifying");
let _enter = span.enter();
let enter = span.enter();
tracing::info!("Starting...");
let mut verifying = Duration::new(0, 0);
@ -64,9 +66,15 @@ impl CLI for RunCommand {
verifying += start.elapsed();
println!(" Verifier time : {:?} milliseconds", verifying.as_millis());
println!(" Verifier output : {}", is_success);
println!(" ");
tracing::info!("Verifier completed in {:?} milliseconds", verifying.as_millis());
// Drop "Verifying" context for console logging
drop(enter);
// Begin "Finished" context for console logging
tracing::span!(tracing::Level::INFO, "Finished").in_scope(|| {
tracing::info!("Verifier output : \"{}\"\n", is_success);
});
Ok(())
}

View File

@ -105,26 +105,31 @@ impl CLI for TestCommand {
let temporary_program = program.clone();
let (passed, failed) = temporary_program.compile_test_constraints(pairs)?;
// Set the result of the test command to PASSED if no tests failed.
let result = if failed == 0 {
"PASSED".to_owned()
} else {
"FAILED".to_owned()
};
// Drop "Test" context for console logging
drop(enter);
// Begin "Finished" context for console logging
tracing::span!(tracing::Level::INFO, "Finished").in_scope(|| {
tracing::info!(
"result: {} in {} milliseconds. {} passed; {} failed;\n",
result,
start.elapsed().as_millis(),
passed,
failed
);
});
// Set the result of the test command to passed if no tests failed.
if failed == 0 {
// Begin "Finished" context for console logging
tracing::span!(tracing::Level::INFO, "Finished").in_scope(|| {
tracing::info!(
"Tests passed in {} milliseconds. {} passed; {} failed;\n",
start.elapsed().as_millis(),
passed,
failed
);
});
} else {
// Begin "Finished" context for console logging
tracing::span!(tracing::Level::ERROR, "Finished").in_scope(|| {
tracing::error!(
"Tests failed in {} milliseconds. {} passed; {} failed;\n",
start.elapsed().as_millis(),
passed,
failed
);
});
};
Ok(())
}

View File

@ -15,6 +15,7 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::errors::*;
use leo_compiler::errors::OutputFileError;
use leo_package::errors::*;
#[derive(Debug, Error)]
@ -67,6 +68,9 @@ pub enum CLIError {
#[error("{}", _0)]
NewError(NewError),
#[error("{}", _0)]
OutputFileError(OutputFileError),
#[error("{}", _0)]
OutputsDirectoryError(OutputsDirectoryError),
@ -134,6 +138,7 @@ impl_cli_error!(
MainFileError,
ManifestError,
NewError,
OutputFileError,
OutputsDirectoryError,
ProofFileError,
ProvingKeyFileError,