diff --git a/leo/commands/build.rs b/leo/commands/build.rs
index 03204e0663..ce108a854e 100644
--- a/leo/commands/build.rs
+++ b/leo/commands/build.rs
@@ -14,26 +14,25 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
-use std::convert::TryFrom;
-
-use anyhow::Result;
+use crate::{
+ commands::Command,
+ context::Context,
+ synthesizer::{CircuitSynthesizer, SerializedCircuit},
+};
use leo_compiler::{compiler::Compiler, group::targets::edwards_bls12::EdwardsGroupType};
use leo_package::{
inputs::*,
outputs::{ChecksumFile, CircuitFile, OutputsDirectory, OUTPUTS_DIRECTORY_NAME},
source::{LibraryFile, MainFile, LIBRARY_FILENAME, MAIN_FILENAME, SOURCE_DIRECTORY_NAME},
};
+
+use anyhow::Result;
use snarkvm_curves::{bls12_377::Bls12_377, edwards_bls12::Fq};
use snarkvm_models::gadgets::r1cs::ConstraintSystem;
+use std::convert::TryFrom;
use structopt::StructOpt;
use tracing::span::Span;
-use crate::{
- commands::Command,
- context::Context,
- synthesizer::{CircuitSynthesizer, SerializedCircuit},
-};
-
/// Compile and build program command
#[derive(StructOpt, Debug, Default)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
diff --git a/leo/commands/clean.rs b/leo/commands/clean.rs
index b88c7deafc..91240f1be7 100644
--- a/leo/commands/clean.rs
+++ b/leo/commands/clean.rs
@@ -14,14 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
-use anyhow::Result;
+use crate::{commands::Command, context::Context};
use leo_compiler::OutputFile;
use leo_package::outputs::{ChecksumFile, CircuitFile, ProofFile, ProvingKeyFile, VerificationKeyFile};
+
+use anyhow::Result;
use structopt::StructOpt;
use tracing::span::Span;
-use crate::{commands::Command, context::Context};
-
/// Clean outputs folder command
#[derive(StructOpt, Debug, Default)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
diff --git a/leo/commands/deploy.rs b/leo/commands/deploy.rs
index 2046039330..f27da1dae5 100644
--- a/leo/commands/deploy.rs
+++ b/leo/commands/deploy.rs
@@ -14,12 +14,12 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
+use crate::{commands::Command, context::Context};
+
use anyhow::Result;
use structopt::StructOpt;
use tracing::span::Span;
-use crate::{commands::Command, context::Context};
-
/// Deploy Leo program to the network
#[derive(StructOpt, Debug, Default)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
diff --git a/leo/commands/init.rs b/leo/commands/init.rs
index 2d161650c6..7ebe2a3214 100644
--- a/leo/commands/init.rs
+++ b/leo/commands/init.rs
@@ -14,26 +14,22 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
-use std::env::current_dir;
+use crate::{commands::Command, context::Context};
+use leo_package::LeoPackage;
use anyhow::{anyhow, Result};
-use leo_package::LeoPackage;
+use std::env::current_dir;
use structopt::StructOpt;
use tracing::span::Span;
-use crate::{commands::Command, context::Context};
-
/// Init Leo project command within current directory
-#[derive(StructOpt, Debug)]
+#[derive(StructOpt, Debug, Default)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
-pub struct Init {
- #[structopt(help = "Init as a library (containing lib.leo)", long = "lib", short = "l")]
- is_lib: Option,
-}
+pub struct Init {}
impl Init {
- pub fn new(is_lib: Option) -> Init {
- Init { is_lib }
+ pub fn new() -> Init {
+ Init {}
}
}
@@ -61,7 +57,7 @@ impl Command for Init {
return Err(anyhow!("Directory does not exist"));
}
- LeoPackage::initialize(&package_name, self.is_lib.unwrap_or(false), &path)?;
+ LeoPackage::initialize(&package_name, false, &path)?;
Ok(())
}
diff --git a/leo/commands/lint.rs b/leo/commands/lint.rs
index b12c5ac3d0..0aeda51844 100644
--- a/leo/commands/lint.rs
+++ b/leo/commands/lint.rs
@@ -14,12 +14,12 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
+use crate::{commands::Command, context::Context};
+
use anyhow::Result;
use structopt::StructOpt;
use tracing::span::Span;
-use crate::{commands::Command, context::Context};
-
/// Lint Leo code command
#[derive(StructOpt, Debug, Default)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
diff --git a/leo/commands/mod.rs b/leo/commands/mod.rs
index 1a5edb1613..8a6ca36171 100644
--- a/leo/commands/mod.rs
+++ b/leo/commands/mod.rs
@@ -14,13 +14,12 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
-use std::time::Instant;
+use crate::context::{get_context, Context};
use anyhow::Result;
+use std::time::Instant;
use tracing::span::Span;
-use crate::context::{get_context, Context};
-
// local program commands
pub mod build;
pub use build::Build;
diff --git a/leo/commands/new.rs b/leo/commands/new.rs
index a75aa26838..2509e7563e 100644
--- a/leo/commands/new.rs
+++ b/leo/commands/new.rs
@@ -14,29 +14,25 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
-use std::{env::current_dir, fs};
+use crate::{commands::Command, context::Context};
+use leo_package::LeoPackage;
use anyhow::{anyhow, Result};
-use leo_package::LeoPackage;
+use std::{env::current_dir, fs};
use structopt::StructOpt;
use tracing::span::Span;
-use crate::{commands::Command, context::Context};
-
/// Create new Leo project
#[derive(StructOpt, Debug)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
pub struct New {
#[structopt(name = "NAME", help = "Set package name")]
name: String,
-
- #[structopt(help = "Init as a library (containing lib.leo)", long = "lib", short = "l")]
- is_lib: bool,
}
impl New {
- pub fn new(name: String, is_lib: bool) -> New {
- New { name, is_lib }
+ pub fn new(name: String) -> New {
+ New { name }
}
}
@@ -67,7 +63,7 @@ impl Command for New {
// Create the package directory
fs::create_dir_all(&path).map_err(|err| anyhow!("Could not create directory {}", err))?;
- LeoPackage::initialize(&package_name, self.is_lib, &path)?;
+ LeoPackage::initialize(&package_name, false, &path)?;
Ok(())
}
diff --git a/leo/commands/package/add.rs b/leo/commands/package/add.rs
index 3afb82710e..6d2da368b4 100644
--- a/leo/commands/package/add.rs
+++ b/leo/commands/package/add.rs
@@ -14,18 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
+use crate::{api::Fetch, commands::Command, context::Context};
+use leo_package::imports::{ImportsDirectory, IMPORTS_DIRECTORY_NAME};
+
+use anyhow::{anyhow, Result};
use std::{
fs::{create_dir_all, File},
io::{Read, Write},
};
-
-use anyhow::{anyhow, Result};
-use leo_package::imports::{ImportsDirectory, IMPORTS_DIRECTORY_NAME};
use structopt::StructOpt;
use tracing::Span;
-use crate::{api::Fetch, commands::Command, context::Context};
-
/// Add package from Aleo Package Manager
#[derive(StructOpt, Debug)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
diff --git a/leo/commands/package/login.rs b/leo/commands/package/login.rs
index 95de02c5a9..597bb79e29 100644
--- a/leo/commands/package/login.rs
+++ b/leo/commands/package/login.rs
@@ -14,12 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
-use std::collections::HashMap;
-
-use anyhow::{anyhow, Result};
-use structopt::StructOpt;
-use tracing::Span;
-
use crate::{
api::{Login as LoginRoute, Profile as ProfileRoute},
commands::Command,
@@ -27,6 +21,11 @@ use crate::{
context::Context,
};
+use anyhow::{anyhow, Result};
+use std::collections::HashMap;
+use structopt::StructOpt;
+use tracing::Span;
+
pub const LOGIN_URL: &str = "v1/account/authenticate";
pub const PROFILE_URL: &str = "v1/account/my_profile";
diff --git a/leo/commands/package/logout.rs b/leo/commands/package/logout.rs
index b62f4be565..0d844ff7ed 100644
--- a/leo/commands/package/logout.rs
+++ b/leo/commands/package/logout.rs
@@ -14,14 +14,13 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
-use std::io::ErrorKind;
+use crate::{commands::Command, config::remove_token, context::Context};
use anyhow::Result;
+use std::io::ErrorKind;
use structopt::StructOpt;
use tracing::Span;
-use crate::{commands::Command, config::remove_token, context::Context};
-
/// Remove credentials for Aleo PM from .leo directory
#[derive(StructOpt, Debug, Default)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
diff --git a/leo/commands/package/publish.rs b/leo/commands/package/publish.rs
index b821e307ba..7b1fceb3a6 100644
--- a/leo/commands/package/publish.rs
+++ b/leo/commands/package/publish.rs
@@ -14,8 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
-use anyhow::{anyhow, Result};
+use super::build::Build;
+use crate::{
+ commands::Command,
+ context::{Context, PACKAGE_MANAGER_URL},
+};
use leo_package::{outputs::OutputsDirectory, root::ZipFile};
+
+use anyhow::{anyhow, Result};
use reqwest::{
blocking::{multipart::Form, Client},
header::{HeaderMap, HeaderValue},
@@ -23,12 +29,6 @@ use reqwest::{
use serde::Deserialize;
use structopt::StructOpt;
-use super::build::Build;
-use crate::{
- commands::Command,
- context::{Context, PACKAGE_MANAGER_URL},
-};
-
pub const PUBLISH_URL: &str = "v1/package/publish";
#[derive(Deserialize)]
diff --git a/leo/commands/package/remove.rs b/leo/commands/package/remove.rs
index 9a7dfcfc7c..2d988fd55e 100644
--- a/leo/commands/package/remove.rs
+++ b/leo/commands/package/remove.rs
@@ -14,13 +14,13 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
-use anyhow::Result;
+use crate::{commands::Command, context::Context};
use leo_package::LeoPackage;
+
+use anyhow::Result;
use structopt::StructOpt;
use tracing::span::Span;
-use crate::{commands::Command, context::Context};
-
/// Remove imported package
#[derive(StructOpt, Debug, Default)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
diff --git a/leo/commands/prove.rs b/leo/commands/prove.rs
index 66e42026c1..bd240be342 100644
--- a/leo/commands/prove.rs
+++ b/leo/commands/prove.rs
@@ -14,19 +14,19 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
-use anyhow::Result;
+use super::setup::Setup;
+use crate::{commands::Command, context::Context};
use leo_package::outputs::ProofFile;
-use rand::thread_rng;
use snarkvm_algorithms::snark::groth16::{Groth16, PreparedVerifyingKey, Proof};
use snarkvm_curves::bls12_377::{Bls12_377, Fr};
use snarkvm_models::algorithms::SNARK;
use snarkvm_utilities::bytes::ToBytes;
+
+use anyhow::Result;
+use rand::thread_rng;
use structopt::StructOpt;
use tracing::span::Span;
-use super::setup::Setup;
-use crate::{commands::Command, context::Context};
-
/// Run the program and produce a proof
#[derive(StructOpt, Debug, Default)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
diff --git a/leo/commands/run.rs b/leo/commands/run.rs
index b079ea9cff..ffb05896fa 100644
--- a/leo/commands/run.rs
+++ b/leo/commands/run.rs
@@ -14,17 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
-use anyhow::Result;
+use super::prove::Prove;
+use crate::{commands::Command, context::Context};
use leo_compiler::{compiler::Compiler, group::targets::edwards_bls12::EdwardsGroupType};
+
+use anyhow::Result;
use snarkvm_algorithms::snark::groth16::Groth16;
use snarkvm_curves::bls12_377::{Bls12_377, Fr};
use snarkvm_models::algorithms::SNARK;
use structopt::StructOpt;
use tracing::span::Span;
-use super::prove::Prove;
-use crate::{commands::Command, context::Context};
-
/// Build, Prove and Run Leo program with inputs
#[derive(StructOpt, Debug, Default)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
diff --git a/leo/commands/setup.rs b/leo/commands/setup.rs
index 240490140a..550934f1e2 100644
--- a/leo/commands/setup.rs
+++ b/leo/commands/setup.rs
@@ -14,12 +14,15 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
-use anyhow::{anyhow, Result};
+use super::build::Build;
+use crate::{commands::Command, context::Context};
use leo_compiler::{compiler::Compiler, group::targets::edwards_bls12::EdwardsGroupType};
use leo_package::{
outputs::{ProvingKeyFile, VerificationKeyFile},
source::{MAIN_FILENAME, SOURCE_DIRECTORY_NAME},
};
+
+use anyhow::{anyhow, Result};
use rand::thread_rng;
use snarkvm_algorithms::snark::groth16::{Groth16, Parameters, PreparedVerifyingKey, VerifyingKey};
use snarkvm_curves::bls12_377::{Bls12_377, Fr};
@@ -27,10 +30,7 @@ use snarkvm_models::algorithms::snark::SNARK;
use structopt::StructOpt;
use tracing::span::Span;
-use super::build::Build;
-use crate::{commands::Command, context::Context};
-
-/// Run a program setup
+/// Executes the setup command for a Leo program
#[derive(StructOpt, Debug, Default)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
pub struct Setup {
@@ -78,7 +78,7 @@ impl Command for Setup {
// Run the program setup operation
let rng = &mut thread_rng();
let (proving_key, prepared_verifying_key) =
- Groth16::, Vec>::setup(&program, rng).unwrap();
+ Groth16::, Vec>::setup(&program, rng)?;
// TODO (howardwu): Convert parameters to a 'proving key' struct for serialization.
// Write the proving key file to the output directory
diff --git a/leo/commands/test.rs b/leo/commands/test.rs
index a9d18d42d9..f9bf89a003 100644
--- a/leo/commands/test.rs
+++ b/leo/commands/test.rs
@@ -14,21 +14,20 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
-use std::{convert::TryFrom, path::PathBuf, time::Instant};
-
-use anyhow::{anyhow, Result};
+use crate::{commands::Command, context::Context};
use leo_compiler::{compiler::Compiler, group::targets::edwards_bls12::EdwardsGroupType};
use leo_package::{
inputs::*,
outputs::{OutputsDirectory, OUTPUTS_DIRECTORY_NAME},
- source::{LibraryFile, MainFile, LIBRARY_FILENAME, MAIN_FILENAME, SOURCE_DIRECTORY_NAME},
+ source::{MainFile, MAIN_FILENAME, SOURCE_DIRECTORY_NAME},
};
+
+use anyhow::{anyhow, Result};
use snarkvm_curves::edwards_bls12::Fq;
+use std::{convert::TryFrom, path::PathBuf, time::Instant};
use structopt::StructOpt;
use tracing::span::Span;
-use crate::{commands::Command, context::Context};
-
/// Build program and run tests command
#[derive(StructOpt, Debug, Default)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
@@ -78,14 +77,7 @@ impl Command for Test {
file_path.push(MAIN_FILENAME);
to_test.push(file_path);
- // if main file is not present and no arguments - try library
- } else if LibraryFile::exists_at(&package_path) {
- let mut file_path = package_path.clone();
- file_path.push(SOURCE_DIRECTORY_NAME);
- file_path.push(LIBRARY_FILENAME);
- to_test.push(file_path);
-
- // nothing found - skip
+ // when no main file and no files marked - error
} else {
return Err(anyhow!(
"Program file does not exist {}",
diff --git a/leo/commands/update.rs b/leo/commands/update.rs
index 9d461004a3..09e0ca640a 100644
--- a/leo/commands/update.rs
+++ b/leo/commands/update.rs
@@ -14,12 +14,12 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
+use crate::{commands::Command, config::Config, context::Context, updater::Updater};
+
use anyhow::{anyhow, Result};
use structopt::StructOpt;
use tracing::span::Span;
-use crate::{commands::Command, config::Config, context::Context, updater::Updater};
-
/// Setting for automatic updates of Leo
#[derive(Debug, StructOpt, PartialEq)]
pub enum Sub {
diff --git a/leo/commands/watch.rs b/leo/commands/watch.rs
index 4f1bb94868..16ae65c2a5 100644
--- a/leo/commands/watch.rs
+++ b/leo/commands/watch.rs
@@ -14,6 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
+use super::build::Build;
+use crate::{commands::Command, context::Context};
+
use std::{sync::mpsc::channel, time::Duration};
use anyhow::{anyhow, Result};
@@ -21,9 +24,6 @@ use notify::{watcher, DebouncedEvent, RecursiveMode, Watcher};
use structopt::StructOpt;
use tracing::span::Span;
-use super::build::Build;
-use crate::{commands::Command, context::Context};
-
const LEO_SOURCE_DIR: &str = "src/";
/// Watch file changes in src/ directory and run Build Command
diff --git a/leo/context.rs b/leo/context.rs
index 2366d73750..077f382428 100644
--- a/leo/context.rs
+++ b/leo/context.rs
@@ -14,12 +14,11 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
-use std::{convert::TryFrom, env::current_dir, path::PathBuf};
-
-use anyhow::Result;
+use crate::{api::Api, config};
use leo_package::root::Manifest;
-use crate::{api::Api, config};
+use anyhow::Result;
+use std::{convert::TryFrom, env::current_dir, path::PathBuf};
pub const PACKAGE_MANAGER_URL: &str = "https://api.aleo.pm/";
diff --git a/leo/main.rs b/leo/main.rs
index 13ba8b803a..846435a9a8 100644
--- a/leo/main.rs
+++ b/leo/main.rs
@@ -22,9 +22,6 @@ pub mod logger;
pub mod synthesizer;
pub mod updater;
-use std::process::exit;
-
-use anyhow::Error;
use commands::{
package::{Add, Login, Logout, Publish, Remove},
Build,
@@ -41,6 +38,9 @@ use commands::{
Update,
Watch,
};
+
+use anyhow::Error;
+use std::process::exit;
use structopt::{clap::AppSettings, StructOpt};
/// CLI Arguments entry point - includes global parameters and subcommands
@@ -61,19 +61,19 @@ struct Opt {
#[derive(StructOpt, Debug)]
#[structopt(setting = AppSettings::ColoredHelp)]
enum CommandOpts {
- #[structopt(about = "Init new Leo project command in current directory")]
+ #[structopt(about = "Create a new Leo package in an existing directory")]
Init {
#[structopt(flatten)]
command: Init,
},
- #[structopt(about = "Create new Leo project in new directory")]
+ #[structopt(about = "Create a new Leo package in a new directory")]
New {
#[structopt(flatten)]
command: New,
},
- #[structopt(about = "Compile current package as a program")]
+ #[structopt(about = "Compile the current package as a program")]
Build {
#[structopt(flatten)]
command: Build,
@@ -97,19 +97,19 @@ enum CommandOpts {
command: Run,
},
- #[structopt(about = "Clean current package: remove proof and circuits")]
+ #[structopt(about = "Clean the output directory")]
Clean {
#[structopt(flatten)]
command: Clean,
},
- #[structopt(about = "Watch for changes of Leo source files and run build")]
+ #[structopt(about = "Watch for changes of Leo source files")]
Watch {
#[structopt(flatten)]
command: Watch,
},
- #[structopt(about = "Watch for changes of Leo source files and run build")]
+ #[structopt(about = "Update Leo to the latest version")]
Update {
#[structopt(flatten)]
command: Update,
@@ -121,37 +121,37 @@ enum CommandOpts {
command: Test,
},
- #[structopt(about = "Import package from Aleo PM")]
+ #[structopt(about = "Install a package from the Aleo Package Manager")]
Add {
#[structopt(flatten)]
command: Add,
},
- #[structopt(about = "Login to the package manager and store credentials")]
+ #[structopt(about = "Login to the Aleo Package Manager")]
Login {
#[structopt(flatten)]
command: Login,
},
- #[structopt(about = "Logout - remove local credentials")]
+ #[structopt(about = "Logout of the package manager and removes credentials")]
Logout {
#[structopt(flatten)]
command: Logout,
},
- #[structopt(about = "Publish package")]
+ #[structopt(about = "Publish the current package to the Aleo Package Manager")]
Publish {
#[structopt(flatten)]
command: Publish,
},
- #[structopt(about = "Remove imported package")]
+ #[structopt(about = "Uninstall a package from the current package")]
Remove {
#[structopt(flatten)]
command: Remove,
},
- #[structopt(about = "Lint package code (not implemented)")]
+ #[structopt(about = "Lints the Leo files in the package (*)")]
Lint {
#[structopt(flatten)]
command: Lint,
diff --git a/leo/updater.rs b/leo/updater.rs
index a7d3db2966..cc5c8972da 100644
--- a/leo/updater.rs
+++ b/leo/updater.rs
@@ -13,12 +13,13 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
+
+use crate::config::Config;
+
use anyhow::{anyhow, Result};
use colored::Colorize;
use self_update::{backends::github, version::bump_is_greater, Status};
-use crate::config::Config;
-
pub struct Updater;
// TODO Add logic for users to easily select release versions.