use crate::{ops::forc_index_deploy, utils::defaults};
use anyhow::Result;
use clap::Parser;
use std::path::PathBuf;
#[derive(Debug, Parser)]
pub struct Command {
#[clap(long, default_value = defaults::INDEXER_SERVICE_HOST, help = "URL at which to deploy indexer assets.")]
pub url: String,
#[clap(
short,
long,
help = "Path to the manifest of indexer project being deployed."
)]
pub manifest: Option<String>,
#[clap(short, long, help = "Path to the indexer project.")]
pub path: Option<PathBuf>,
#[clap(long, help = "Authentication header value.")]
pub auth: Option<String>,
#[clap(long, default_value = defaults::INDEXER_TARGET, help = "Target at which to compile.")]
pub target: String,
#[clap(
short,
long,
help = "Build optimized artifacts with the release profile.",
default_value = defaults::BUILD_RELEASE_PROFILE,
)]
pub release: String,
#[clap(long, help = "Build with the given profile.")]
pub profile: Option<String>,
#[clap(long, help = "Ensure that the Cargo.lock file is up-to-date.")]
pub locked: bool,
#[clap(long, help = "Building for native execution.")]
pub native: bool,
#[clap(
long,
help = "Directory for all generated artifacts and intermediate files."
)]
pub target_dir: Option<PathBuf>,
#[clap(short, long, help = "Enable verbose logging.")]
pub verbose: bool,
#[clap(long, help = "Do not build before deploying.")]
pub skip_build: bool,
}
impl Default for Command {
fn default() -> Self {
Command {
url: "http://127.0.0.1:29987".to_string(),
manifest: Some(String::new()),
path: None,
auth: Some("".to_string()),
target: defaults::WASM_TARGET.to_string(),
release: true.to_string(),
profile: Some("release".to_string()),
verbose: false,
locked: false,
native: false,
skip_build: false,
target_dir: Some(std::path::PathBuf::from(".")),
}
}
}
pub fn exec(command: Command) -> Result<()> {
forc_index_deploy::init(command)?;
Ok(())
}