Adds skeleton for 'leo load' and 'leo unload'

This commit is contained in:
howardwu 2020-05-16 20:35:37 -07:00
parent 426bb46662
commit 63ed971b4d
9 changed files with 102 additions and 10 deletions

View File

@ -22,7 +22,7 @@ impl CLI for BuildCommand {
type Output = (Compiler<Fr, EdwardsProjective>, bool);
const NAME: NameType = "build";
const ABOUT: AboutType = "Compile the package as a program";
const ABOUT: AboutType = "Compile the current package as a program";
const ARGUMENTS: &'static [ArgumentType] = &[];
const FLAGS: &'static [FlagType] = &[];
const OPTIONS: &'static [OptionType] = &[];

View File

@ -15,7 +15,7 @@ impl CLI for DeployCommand {
type Output = ();
const NAME: NameType = "deploy";
const ABOUT: AboutType = "Deploy the package as a program to the network (*)";
const ABOUT: AboutType = "Deploy the current package as a program to the network (*)";
const ARGUMENTS: &'static [ArgumentType] = &[];
const FLAGS: &'static [FlagType] = &[];
const OPTIONS: &'static [OptionType] = &[];

View File

@ -14,7 +14,7 @@ impl CLI for InitCommand {
type Output = ();
const NAME: NameType = "init";
const ABOUT: AboutType = "Creates a new Leo package in an existing directory";
const ABOUT: AboutType = "Create a new Leo package in an existing directory";
const ARGUMENTS: &'static [ArgumentType] = &[];
const FLAGS: &'static [FlagType] = &[];
const OPTIONS: &'static [OptionType] = &[];

41
leo/commands/load.rs Normal file
View File

@ -0,0 +1,41 @@
use crate::{cli::*, cli_types::*};
use crate::commands::BuildCommand;
use crate::errors::CLIError;
use crate::files::Manifest;
use clap::ArgMatches;
use std::convert::TryFrom;
use std::env::current_dir;
#[derive(Debug)]
pub struct LoadCommand;
impl CLI for LoadCommand {
type Options = ();
type Output = ();
const NAME: NameType = "load";
const ABOUT: AboutType = "Install a package from the package manager (*)";
const ARGUMENTS: &'static [ArgumentType] = &[];
const FLAGS: &'static [FlagType] = &[];
const OPTIONS: &'static [OptionType] = &[];
const SUBCOMMANDS: &'static [SubCommandType] = &[];
#[cfg_attr(tarpaulin, skip)]
fn parse(_arguments: &ArgMatches) -> Result<Self::Options, CLIError> {
Ok(())
}
#[cfg_attr(tarpaulin, skip)]
fn output(options: Self::Options) -> Result<Self::Output, CLIError> {
let (_program, _checksum_differs) = BuildCommand::output(options)?;
// Get the package name
let path = current_dir()?;
let _package_name = Manifest::try_from(&path)?.get_package_name();
log::info!("Unimplemented - `leo deploy`");
Ok(())
}
}

View File

@ -7,6 +7,9 @@ pub use self::deploy::*;
pub mod init;
pub use self::init::*;
pub mod load;
pub use self::load::*;
pub mod new;
pub use self::new::*;
@ -21,3 +24,6 @@ pub use self::run::*;
pub mod setup;
pub use self::setup::*;
pub mod unload;
pub use self::unload::*;

View File

@ -15,7 +15,7 @@ impl CLI for NewCommand {
type Output = ();
const NAME: NameType = "new";
const ABOUT: AboutType = "Creates a new Leo package";
const ABOUT: AboutType = "Create a new Leo package in a new directory";
const ARGUMENTS: &'static [ArgumentType] = &[
// (name, description, required, index)
(

View File

@ -15,7 +15,7 @@ impl CLI for PublishCommand {
type Output = ();
const NAME: NameType = "publish";
const ABOUT: AboutType = "Publish the package to the package manager (*)";
const ABOUT: AboutType = "Publish the current package to the package manager (*)";
const ARGUMENTS: &'static [ArgumentType] = &[];
const FLAGS: &'static [FlagType] = &[];
const OPTIONS: &'static [OptionType] = &[];

41
leo/commands/unload.rs Normal file
View File

@ -0,0 +1,41 @@
use crate::{cli::*, cli_types::*};
use crate::commands::BuildCommand;
use crate::errors::CLIError;
use crate::files::Manifest;
use clap::ArgMatches;
use std::convert::TryFrom;
use std::env::current_dir;
#[derive(Debug)]
pub struct UnloadCommand;
impl CLI for UnloadCommand {
type Options = ();
type Output = ();
const NAME: NameType = "unload";
const ABOUT: AboutType = "Uninstall a package from the current package (*)";
const ARGUMENTS: &'static [ArgumentType] = &[];
const FLAGS: &'static [FlagType] = &[];
const OPTIONS: &'static [OptionType] = &[];
const SUBCOMMANDS: &'static [SubCommandType] = &[];
#[cfg_attr(tarpaulin, skip)]
fn parse(_arguments: &ArgMatches) -> Result<Self::Options, CLIError> {
Ok(())
}
#[cfg_attr(tarpaulin, skip)]
fn output(options: Self::Options) -> Result<Self::Output, CLIError> {
let (_program, _checksum_differs) = BuildCommand::output(options)?;
// Get the package name
let path = current_dir()?;
let _package_name = Manifest::try_from(&path)?.get_package_name();
log::info!("Unimplemented - `leo deploy`");
Ok(())
}
}

View File

@ -21,11 +21,13 @@ fn main() -> Result<(), CLIError> {
NewCommand::new().display_order(0),
InitCommand::new().display_order(1),
BuildCommand::new().display_order(2),
SetupCommand::new().display_order(3),
ProveCommand::new().display_order(4),
RunCommand::new().display_order(5),
PublishCommand::new().display_order(6),
DeployCommand::new().display_order(7),
LoadCommand::new().display_order(3),
UnloadCommand::new().display_order(4),
SetupCommand::new().display_order(5),
ProveCommand::new().display_order(6),
RunCommand::new().display_order(7),
PublishCommand::new().display_order(8),
DeployCommand::new().display_order(9),
])
.set_term_width(0)
.get_matches();
@ -37,6 +39,8 @@ fn main() -> Result<(), CLIError> {
BuildCommand::output(BuildCommand::parse(arguments)?)?;
Ok(())
}
("load", Some(arguments)) => LoadCommand::output(LoadCommand::parse(arguments)?),
("unload", Some(arguments)) => UnloadCommand::output(UnloadCommand::parse(arguments)?),
("setup", Some(arguments)) => {
SetupCommand::output(SetupCommand::parse(arguments)?)?;
Ok(())