Skip to content

Commit

Permalink
Clean up other forc index commands
Browse files Browse the repository at this point in the history
  • Loading branch information
deekerno committed Dec 8, 2022
1 parent 47a1ab8 commit 60b2201
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 44 deletions.
2 changes: 1 addition & 1 deletion plugins/forc-index/src/commands/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use anyhow::Result;
use clap::Parser;
use std::path::PathBuf;

/// Create a new Forc project in an existing directory.
/// Deploy an index asset bundle to a remote or locally running indexer server.
#[derive(Debug, Parser)]
pub struct Command {
/// URL at which to upload index assets
Expand Down
2 changes: 1 addition & 1 deletion plugins/forc-index/src/commands/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use anyhow::Result;
use clap::Parser;
use std::path::PathBuf;

/// Create a new Forc project in the current directory.
/// Create a new indexer project in the current directory.
#[derive(Debug, Parser)]
pub struct Command {
/// Name of index
Expand Down
2 changes: 1 addition & 1 deletion plugins/forc-index/src/commands/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use anyhow::Result;
use clap::Parser;
use std::path::PathBuf;

/// Create a new Forc project in an existing directory.
/// Create a new indexer project in a new directory.
#[derive(Debug, Parser)]
pub struct Command {
/// Name of index
Expand Down
2 changes: 1 addition & 1 deletion plugins/forc-index/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use anyhow::Result;
use clap::Parser;
use std::path::PathBuf;

/// Create a new Forc project in an existing directory.
/// Start a local indexer service.
#[derive(Debug, Parser)]
pub struct Command {
/// Log level passed to the Fuel Indexer service.
Expand Down
41 changes: 1 addition & 40 deletions plugins/forc-index/src/ops/forc_index_deploy.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::cli::DeployCommand;
use crate::{cli::DeployCommand, utils::extract_manifest_fields};
use reqwest::{
blocking::{multipart::Form, Client},
header::{HeaderMap, AUTHORIZATION},
Expand All @@ -10,45 +10,6 @@ use std::io::{BufReader, Read};
use std::path::Path;
use tracing::{error, info};

fn extract_manifest_fields(
manifest: serde_yaml::Value,
) -> anyhow::Result<(String, String, String, String)> {
let namespace: String = manifest
.get(&serde_yaml::Value::String("namespace".into()))
.unwrap()
.as_str()
.unwrap()
.to_string();
let identifier: String = manifest
.get(&serde_yaml::Value::String("identifier".into()))
.unwrap()
.as_str()
.unwrap()
.to_string();
let graphql_schema: String = manifest
.get(&serde_yaml::Value::String("graphql_schema".into()))
.unwrap()
.as_str()
.unwrap()
.to_string();
let module: serde_yaml::Value = manifest
.get(&serde_yaml::Value::String("module".into()))
.unwrap()
.to_owned();
let module_path: String = module
.get(&serde_yaml::Value::String("wasm".into()))
.unwrap_or_else(|| {
module
.get(&serde_yaml::Value::String("native".into()))
.unwrap()
})
.as_str()
.unwrap()
.to_string();

Ok((namespace, identifier, graphql_schema, module_path))
}

pub fn init(command: DeployCommand) -> anyhow::Result<()> {
let mut manifest_file = fs::File::open(&command.manifest).unwrap_or_else(|_| {
panic!(
Expand Down

0 comments on commit 60b2201

Please sign in to comment.