imports sorting, --lib flag removed

- leo new/init now don't have --lib flag
- imports sorted
- command descriptions match old ones 1-to-1
This commit is contained in:
damirka 2021-02-10 19:18:04 +03:00
parent deb830ce65
commit 7867ab9d54
21 changed files with 99 additions and 120 deletions

View File

@ -14,26 +14,25 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use std::convert::TryFrom; use crate::{
commands::Command,
use anyhow::Result; context::Context,
synthesizer::{CircuitSynthesizer, SerializedCircuit},
};
use leo_compiler::{compiler::Compiler, group::targets::edwards_bls12::EdwardsGroupType}; use leo_compiler::{compiler::Compiler, group::targets::edwards_bls12::EdwardsGroupType};
use leo_package::{ use leo_package::{
inputs::*, inputs::*,
outputs::{ChecksumFile, CircuitFile, OutputsDirectory, OUTPUTS_DIRECTORY_NAME}, outputs::{ChecksumFile, CircuitFile, OutputsDirectory, OUTPUTS_DIRECTORY_NAME},
source::{LibraryFile, MainFile, LIBRARY_FILENAME, MAIN_FILENAME, SOURCE_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_curves::{bls12_377::Bls12_377, edwards_bls12::Fq};
use snarkvm_models::gadgets::r1cs::ConstraintSystem; use snarkvm_models::gadgets::r1cs::ConstraintSystem;
use std::convert::TryFrom;
use structopt::StructOpt; use structopt::StructOpt;
use tracing::span::Span; use tracing::span::Span;
use crate::{
commands::Command,
context::Context,
synthesizer::{CircuitSynthesizer, SerializedCircuit},
};
/// Compile and build program command /// Compile and build program command
#[derive(StructOpt, Debug, Default)] #[derive(StructOpt, Debug, Default)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] #[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]

View File

@ -14,14 +14,14 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use anyhow::Result; use crate::{commands::Command, context::Context};
use leo_compiler::OutputFile; use leo_compiler::OutputFile;
use leo_package::outputs::{ChecksumFile, CircuitFile, ProofFile, ProvingKeyFile, VerificationKeyFile}; use leo_package::outputs::{ChecksumFile, CircuitFile, ProofFile, ProvingKeyFile, VerificationKeyFile};
use anyhow::Result;
use structopt::StructOpt; use structopt::StructOpt;
use tracing::span::Span; use tracing::span::Span;
use crate::{commands::Command, context::Context};
/// Clean outputs folder command /// Clean outputs folder command
#[derive(StructOpt, Debug, Default)] #[derive(StructOpt, Debug, Default)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] #[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]

View File

@ -14,12 +14,12 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{commands::Command, context::Context};
use anyhow::Result; use anyhow::Result;
use structopt::StructOpt; use structopt::StructOpt;
use tracing::span::Span; use tracing::span::Span;
use crate::{commands::Command, context::Context};
/// Deploy Leo program to the network /// Deploy Leo program to the network
#[derive(StructOpt, Debug, Default)] #[derive(StructOpt, Debug, Default)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] #[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]

View File

@ -14,26 +14,22 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use std::env::current_dir; use crate::{commands::Command, context::Context};
use leo_package::LeoPackage;
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use leo_package::LeoPackage; use std::env::current_dir;
use structopt::StructOpt; use structopt::StructOpt;
use tracing::span::Span; use tracing::span::Span;
use crate::{commands::Command, context::Context};
/// Init Leo project command within current directory /// Init Leo project command within current directory
#[derive(StructOpt, Debug)] #[derive(StructOpt, Debug, Default)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] #[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
pub struct Init { pub struct Init {}
#[structopt(help = "Init as a library (containing lib.leo)", long = "lib", short = "l")]
is_lib: Option<bool>,
}
impl Init { impl Init {
pub fn new(is_lib: Option<bool>) -> Init { pub fn new() -> Init {
Init { is_lib } Init {}
} }
} }
@ -61,7 +57,7 @@ impl Command for Init {
return Err(anyhow!("Directory does not exist")); 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(()) Ok(())
} }

View File

@ -14,12 +14,12 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{commands::Command, context::Context};
use anyhow::Result; use anyhow::Result;
use structopt::StructOpt; use structopt::StructOpt;
use tracing::span::Span; use tracing::span::Span;
use crate::{commands::Command, context::Context};
/// Lint Leo code command /// Lint Leo code command
#[derive(StructOpt, Debug, Default)] #[derive(StructOpt, Debug, Default)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] #[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]

View File

@ -14,13 +14,12 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use std::time::Instant; use crate::context::{get_context, Context};
use anyhow::Result; use anyhow::Result;
use std::time::Instant;
use tracing::span::Span; use tracing::span::Span;
use crate::context::{get_context, Context};
// local program commands // local program commands
pub mod build; pub mod build;
pub use build::Build; pub use build::Build;

View File

@ -14,29 +14,25 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use std::{env::current_dir, fs}; use crate::{commands::Command, context::Context};
use leo_package::LeoPackage;
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use leo_package::LeoPackage; use std::{env::current_dir, fs};
use structopt::StructOpt; use structopt::StructOpt;
use tracing::span::Span; use tracing::span::Span;
use crate::{commands::Command, context::Context};
/// Create new Leo project /// Create new Leo project
#[derive(StructOpt, Debug)] #[derive(StructOpt, Debug)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] #[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
pub struct New { pub struct New {
#[structopt(name = "NAME", help = "Set package name")] #[structopt(name = "NAME", help = "Set package name")]
name: String, name: String,
#[structopt(help = "Init as a library (containing lib.leo)", long = "lib", short = "l")]
is_lib: bool,
} }
impl New { impl New {
pub fn new(name: String, is_lib: bool) -> New { pub fn new(name: String) -> New {
New { name, is_lib } New { name }
} }
} }
@ -67,7 +63,7 @@ impl Command for New {
// Create the package directory // Create the package directory
fs::create_dir_all(&path).map_err(|err| anyhow!("Could not create directory {}", err))?; 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(()) Ok(())
} }

View File

@ -14,18 +14,17 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{api::Fetch, commands::Command, context::Context};
use leo_package::imports::{ImportsDirectory, IMPORTS_DIRECTORY_NAME};
use anyhow::{anyhow, Result};
use std::{ use std::{
fs::{create_dir_all, File}, fs::{create_dir_all, File},
io::{Read, Write}, io::{Read, Write},
}; };
use anyhow::{anyhow, Result};
use leo_package::imports::{ImportsDirectory, IMPORTS_DIRECTORY_NAME};
use structopt::StructOpt; use structopt::StructOpt;
use tracing::Span; use tracing::Span;
use crate::{api::Fetch, commands::Command, context::Context};
/// Add package from Aleo Package Manager /// Add package from Aleo Package Manager
#[derive(StructOpt, Debug)] #[derive(StructOpt, Debug)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] #[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]

View File

@ -14,12 +14,6 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use std::collections::HashMap;
use anyhow::{anyhow, Result};
use structopt::StructOpt;
use tracing::Span;
use crate::{ use crate::{
api::{Login as LoginRoute, Profile as ProfileRoute}, api::{Login as LoginRoute, Profile as ProfileRoute},
commands::Command, commands::Command,
@ -27,6 +21,11 @@ use crate::{
context::Context, 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 LOGIN_URL: &str = "v1/account/authenticate";
pub const PROFILE_URL: &str = "v1/account/my_profile"; pub const PROFILE_URL: &str = "v1/account/my_profile";

View File

@ -14,14 +14,13 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use std::io::ErrorKind; use crate::{commands::Command, config::remove_token, context::Context};
use anyhow::Result; use anyhow::Result;
use std::io::ErrorKind;
use structopt::StructOpt; use structopt::StructOpt;
use tracing::Span; use tracing::Span;
use crate::{commands::Command, config::remove_token, context::Context};
/// Remove credentials for Aleo PM from .leo directory /// Remove credentials for Aleo PM from .leo directory
#[derive(StructOpt, Debug, Default)] #[derive(StructOpt, Debug, Default)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] #[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]

View File

@ -14,8 +14,14 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
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 leo_package::{outputs::OutputsDirectory, root::ZipFile};
use anyhow::{anyhow, Result};
use reqwest::{ use reqwest::{
blocking::{multipart::Form, Client}, blocking::{multipart::Form, Client},
header::{HeaderMap, HeaderValue}, header::{HeaderMap, HeaderValue},
@ -23,12 +29,6 @@ use reqwest::{
use serde::Deserialize; use serde::Deserialize;
use structopt::StructOpt; use structopt::StructOpt;
use super::build::Build;
use crate::{
commands::Command,
context::{Context, PACKAGE_MANAGER_URL},
};
pub const PUBLISH_URL: &str = "v1/package/publish"; pub const PUBLISH_URL: &str = "v1/package/publish";
#[derive(Deserialize)] #[derive(Deserialize)]

View File

@ -14,13 +14,13 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use anyhow::Result; use crate::{commands::Command, context::Context};
use leo_package::LeoPackage; use leo_package::LeoPackage;
use anyhow::Result;
use structopt::StructOpt; use structopt::StructOpt;
use tracing::span::Span; use tracing::span::Span;
use crate::{commands::Command, context::Context};
/// Remove imported package /// Remove imported package
#[derive(StructOpt, Debug, Default)] #[derive(StructOpt, Debug, Default)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] #[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]

View File

@ -14,19 +14,19 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use anyhow::Result; use super::setup::Setup;
use crate::{commands::Command, context::Context};
use leo_package::outputs::ProofFile; use leo_package::outputs::ProofFile;
use rand::thread_rng;
use snarkvm_algorithms::snark::groth16::{Groth16, PreparedVerifyingKey, Proof}; use snarkvm_algorithms::snark::groth16::{Groth16, PreparedVerifyingKey, Proof};
use snarkvm_curves::bls12_377::{Bls12_377, Fr}; use snarkvm_curves::bls12_377::{Bls12_377, Fr};
use snarkvm_models::algorithms::SNARK; use snarkvm_models::algorithms::SNARK;
use snarkvm_utilities::bytes::ToBytes; use snarkvm_utilities::bytes::ToBytes;
use anyhow::Result;
use rand::thread_rng;
use structopt::StructOpt; use structopt::StructOpt;
use tracing::span::Span; use tracing::span::Span;
use super::setup::Setup;
use crate::{commands::Command, context::Context};
/// Run the program and produce a proof /// Run the program and produce a proof
#[derive(StructOpt, Debug, Default)] #[derive(StructOpt, Debug, Default)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] #[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]

View File

@ -14,17 +14,17 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use anyhow::Result; use super::prove::Prove;
use crate::{commands::Command, context::Context};
use leo_compiler::{compiler::Compiler, group::targets::edwards_bls12::EdwardsGroupType}; use leo_compiler::{compiler::Compiler, group::targets::edwards_bls12::EdwardsGroupType};
use anyhow::Result;
use snarkvm_algorithms::snark::groth16::Groth16; use snarkvm_algorithms::snark::groth16::Groth16;
use snarkvm_curves::bls12_377::{Bls12_377, Fr}; use snarkvm_curves::bls12_377::{Bls12_377, Fr};
use snarkvm_models::algorithms::SNARK; use snarkvm_models::algorithms::SNARK;
use structopt::StructOpt; use structopt::StructOpt;
use tracing::span::Span; use tracing::span::Span;
use super::prove::Prove;
use crate::{commands::Command, context::Context};
/// Build, Prove and Run Leo program with inputs /// Build, Prove and Run Leo program with inputs
#[derive(StructOpt, Debug, Default)] #[derive(StructOpt, Debug, Default)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] #[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]

View File

@ -14,12 +14,15 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
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_compiler::{compiler::Compiler, group::targets::edwards_bls12::EdwardsGroupType};
use leo_package::{ use leo_package::{
outputs::{ProvingKeyFile, VerificationKeyFile}, outputs::{ProvingKeyFile, VerificationKeyFile},
source::{MAIN_FILENAME, SOURCE_DIRECTORY_NAME}, source::{MAIN_FILENAME, SOURCE_DIRECTORY_NAME},
}; };
use anyhow::{anyhow, Result};
use rand::thread_rng; use rand::thread_rng;
use snarkvm_algorithms::snark::groth16::{Groth16, Parameters, PreparedVerifyingKey, VerifyingKey}; use snarkvm_algorithms::snark::groth16::{Groth16, Parameters, PreparedVerifyingKey, VerifyingKey};
use snarkvm_curves::bls12_377::{Bls12_377, Fr}; use snarkvm_curves::bls12_377::{Bls12_377, Fr};
@ -27,10 +30,7 @@ use snarkvm_models::algorithms::snark::SNARK;
use structopt::StructOpt; use structopt::StructOpt;
use tracing::span::Span; use tracing::span::Span;
use super::build::Build; /// Executes the setup command for a Leo program
use crate::{commands::Command, context::Context};
/// Run a program setup
#[derive(StructOpt, Debug, Default)] #[derive(StructOpt, Debug, Default)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] #[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
pub struct Setup { pub struct Setup {
@ -78,7 +78,7 @@ impl Command for Setup {
// Run the program setup operation // Run the program setup operation
let rng = &mut thread_rng(); let rng = &mut thread_rng();
let (proving_key, prepared_verifying_key) = let (proving_key, prepared_verifying_key) =
Groth16::<Bls12_377, Compiler<Fr, _>, Vec<Fr>>::setup(&program, rng).unwrap(); Groth16::<Bls12_377, Compiler<Fr, _>, Vec<Fr>>::setup(&program, rng)?;
// TODO (howardwu): Convert parameters to a 'proving key' struct for serialization. // TODO (howardwu): Convert parameters to a 'proving key' struct for serialization.
// Write the proving key file to the output directory // Write the proving key file to the output directory

View File

@ -14,21 +14,20 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use std::{convert::TryFrom, path::PathBuf, time::Instant}; use crate::{commands::Command, context::Context};
use anyhow::{anyhow, Result};
use leo_compiler::{compiler::Compiler, group::targets::edwards_bls12::EdwardsGroupType}; use leo_compiler::{compiler::Compiler, group::targets::edwards_bls12::EdwardsGroupType};
use leo_package::{ use leo_package::{
inputs::*, inputs::*,
outputs::{OutputsDirectory, OUTPUTS_DIRECTORY_NAME}, 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 snarkvm_curves::edwards_bls12::Fq;
use std::{convert::TryFrom, path::PathBuf, time::Instant};
use structopt::StructOpt; use structopt::StructOpt;
use tracing::span::Span; use tracing::span::Span;
use crate::{commands::Command, context::Context};
/// Build program and run tests command /// Build program and run tests command
#[derive(StructOpt, Debug, Default)] #[derive(StructOpt, Debug, Default)]
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] #[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
@ -78,14 +77,7 @@ impl Command for Test {
file_path.push(MAIN_FILENAME); file_path.push(MAIN_FILENAME);
to_test.push(file_path); to_test.push(file_path);
// if main file is not present and no arguments - try library // when no main file and no files marked - error
} 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
} else { } else {
return Err(anyhow!( return Err(anyhow!(
"Program file does not exist {}", "Program file does not exist {}",

View File

@ -14,12 +14,12 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{commands::Command, config::Config, context::Context, updater::Updater};
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use structopt::StructOpt; use structopt::StructOpt;
use tracing::span::Span; use tracing::span::Span;
use crate::{commands::Command, config::Config, context::Context, updater::Updater};
/// Setting for automatic updates of Leo /// Setting for automatic updates of Leo
#[derive(Debug, StructOpt, PartialEq)] #[derive(Debug, StructOpt, PartialEq)]
pub enum Sub { pub enum Sub {

View File

@ -14,6 +14,9 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use super::build::Build;
use crate::{commands::Command, context::Context};
use std::{sync::mpsc::channel, time::Duration}; use std::{sync::mpsc::channel, time::Duration};
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
@ -21,9 +24,6 @@ use notify::{watcher, DebouncedEvent, RecursiveMode, Watcher};
use structopt::StructOpt; use structopt::StructOpt;
use tracing::span::Span; use tracing::span::Span;
use super::build::Build;
use crate::{commands::Command, context::Context};
const LEO_SOURCE_DIR: &str = "src/"; const LEO_SOURCE_DIR: &str = "src/";
/// Watch file changes in src/ directory and run Build Command /// Watch file changes in src/ directory and run Build Command

View File

@ -14,12 +14,11 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use std::{convert::TryFrom, env::current_dir, path::PathBuf}; use crate::{api::Api, config};
use anyhow::Result;
use leo_package::root::Manifest; 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/"; pub const PACKAGE_MANAGER_URL: &str = "https://api.aleo.pm/";

View File

@ -22,9 +22,6 @@ pub mod logger;
pub mod synthesizer; pub mod synthesizer;
pub mod updater; pub mod updater;
use std::process::exit;
use anyhow::Error;
use commands::{ use commands::{
package::{Add, Login, Logout, Publish, Remove}, package::{Add, Login, Logout, Publish, Remove},
Build, Build,
@ -41,6 +38,9 @@ use commands::{
Update, Update,
Watch, Watch,
}; };
use anyhow::Error;
use std::process::exit;
use structopt::{clap::AppSettings, StructOpt}; use structopt::{clap::AppSettings, StructOpt};
/// CLI Arguments entry point - includes global parameters and subcommands /// CLI Arguments entry point - includes global parameters and subcommands
@ -61,19 +61,19 @@ struct Opt {
#[derive(StructOpt, Debug)] #[derive(StructOpt, Debug)]
#[structopt(setting = AppSettings::ColoredHelp)] #[structopt(setting = AppSettings::ColoredHelp)]
enum CommandOpts { enum CommandOpts {
#[structopt(about = "Init new Leo project command in current directory")] #[structopt(about = "Create a new Leo package in an existing directory")]
Init { Init {
#[structopt(flatten)] #[structopt(flatten)]
command: Init, command: Init,
}, },
#[structopt(about = "Create new Leo project in new directory")] #[structopt(about = "Create a new Leo package in a new directory")]
New { New {
#[structopt(flatten)] #[structopt(flatten)]
command: New, command: New,
}, },
#[structopt(about = "Compile current package as a program")] #[structopt(about = "Compile the current package as a program")]
Build { Build {
#[structopt(flatten)] #[structopt(flatten)]
command: Build, command: Build,
@ -97,19 +97,19 @@ enum CommandOpts {
command: Run, command: Run,
}, },
#[structopt(about = "Clean current package: remove proof and circuits")] #[structopt(about = "Clean the output directory")]
Clean { Clean {
#[structopt(flatten)] #[structopt(flatten)]
command: Clean, command: Clean,
}, },
#[structopt(about = "Watch for changes of Leo source files and run build")] #[structopt(about = "Watch for changes of Leo source files")]
Watch { Watch {
#[structopt(flatten)] #[structopt(flatten)]
command: Watch, command: Watch,
}, },
#[structopt(about = "Watch for changes of Leo source files and run build")] #[structopt(about = "Update Leo to the latest version")]
Update { Update {
#[structopt(flatten)] #[structopt(flatten)]
command: Update, command: Update,
@ -121,37 +121,37 @@ enum CommandOpts {
command: Test, command: Test,
}, },
#[structopt(about = "Import package from Aleo PM")] #[structopt(about = "Install a package from the Aleo Package Manager")]
Add { Add {
#[structopt(flatten)] #[structopt(flatten)]
command: Add, command: Add,
}, },
#[structopt(about = "Login to the package manager and store credentials")] #[structopt(about = "Login to the Aleo Package Manager")]
Login { Login {
#[structopt(flatten)] #[structopt(flatten)]
command: Login, command: Login,
}, },
#[structopt(about = "Logout - remove local credentials")] #[structopt(about = "Logout of the package manager and removes credentials")]
Logout { Logout {
#[structopt(flatten)] #[structopt(flatten)]
command: Logout, command: Logout,
}, },
#[structopt(about = "Publish package")] #[structopt(about = "Publish the current package to the Aleo Package Manager")]
Publish { Publish {
#[structopt(flatten)] #[structopt(flatten)]
command: Publish, command: Publish,
}, },
#[structopt(about = "Remove imported package")] #[structopt(about = "Uninstall a package from the current package")]
Remove { Remove {
#[structopt(flatten)] #[structopt(flatten)]
command: Remove, command: Remove,
}, },
#[structopt(about = "Lint package code (not implemented)")] #[structopt(about = "Lints the Leo files in the package (*)")]
Lint { Lint {
#[structopt(flatten)] #[structopt(flatten)]
command: Lint, command: Lint,

View File

@ -13,12 +13,13 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::config::Config;
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use colored::Colorize; use colored::Colorize;
use self_update::{backends::github, version::bump_is_greater, Status}; use self_update::{backends::github, version::bump_is_greater, Status};
use crate::config::Config;
pub struct Updater; pub struct Updater;
// TODO Add logic for users to easily select release versions. // TODO Add logic for users to easily select release versions.