Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
csgui committed Aug 3, 2023
1 parent 7d48bdc commit d8f2f38
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions components/clarinet-cli/src/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ extern crate hiro_system_kit;

mod chainhooks;
mod deployments;
mod devnet;
mod frontend;
mod generate;
pub mod integrate;
mod lsp;
mod runner;
mod devnet;

use frontend::cli;

pub fn main() {
cli::main();
}
}
2 changes: 1 addition & 1 deletion components/clarinet-cli/src/devnet/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pub mod package;
pub mod package;
29 changes: 15 additions & 14 deletions components/clarinet-cli/src/devnet/package.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::process;
use std::fs::{File, read_to_string};
use std::fs::{read_to_string, File};
use std::io::{self, Write};
use std::process;

use clarinet_deployments::types::DeploymentSpecificationFile;
use clarinet_files::NetworkManifestFile;
Expand All @@ -13,21 +13,21 @@ struct Project {
description: Option<String>,
authors: Vec<String>,
telemetry: Option<bool>,
cache_dir: Option<String>
cache_dir: Option<String>,
}

#[derive(Serialize, Deserialize, Debug)]
struct ClarinetSpecificationFile {
project: Project,
contracts: Option<Value>,
repl: Option<Value>
repl: Option<Value>,
}

#[derive(Serialize, Deserialize, Debug)]
struct ConfigurationPackage {
deployment_plan: DeploymentSpecificationFile,
devnet_config: NetworkManifestFile,
clarinet_config: ClarinetSpecificationFile
clarinet_config: ClarinetSpecificationFile,
}

fn get_devnet_config() -> NetworkManifestFile {
Expand Down Expand Up @@ -59,7 +59,8 @@ fn get_clarinet_config() -> ClarinetSpecificationFile {
}
};

let clarinet_config: ClarinetSpecificationFile = match toml::from_str(&clarinet_config_content) {
let clarinet_config: ClarinetSpecificationFile = match toml::from_str(&clarinet_config_content)
{
Ok(data) => data,
Err(err) => {
println!("Unable to load data from Clarinet.toml file: {}", err);
Expand All @@ -72,7 +73,8 @@ fn get_clarinet_config() -> ClarinetSpecificationFile {

fn get_deployment_plan() -> DeploymentSpecificationFile {
let deployment_spec_file = File::open("./deployments/default.simnet-plan.yaml").unwrap();
let deployment_plan: DeploymentSpecificationFile = serde_yaml::from_reader(deployment_spec_file).unwrap();
let deployment_plan: DeploymentSpecificationFile =
serde_yaml::from_reader(deployment_spec_file).unwrap();

deployment_plan
}
Expand All @@ -92,29 +94,28 @@ fn pack_to_file(file_name: &str) -> Result<(), io::Error> {
};

let package = ConfigurationPackage {
deployment_plan : get_deployment_plan(),
deployment_plan: get_deployment_plan(),
devnet_config: get_devnet_config(),
clarinet_config: get_clarinet_config()
clarinet_config: get_clarinet_config(),
};

match serde_json::to_writer(file, &package) {
Ok(_) => println!("{} file generated with success", file_name),
Err(e) => println!("Unable to generate the json file: {}", e)
Err(e) => println!("Unable to generate the json file: {}", e),
};

Ok(())
}

fn pack_to_stdout() {
let package = ConfigurationPackage {
deployment_plan : get_deployment_plan(),
deployment_plan: get_deployment_plan(),
devnet_config: get_devnet_config(),
clarinet_config: get_clarinet_config()
clarinet_config: get_clarinet_config(),
};

let s = serde_json::to_string(&package).unwrap();
io::stdout().write(s.as_bytes()).ok();

}

pub fn pack(file_name: Option<String>) -> Result<(), io::Error> {
Expand All @@ -124,4 +125,4 @@ pub fn pack(file_name: Option<String>) -> Result<(), io::Error> {
}

Ok(())
}
}
17 changes: 8 additions & 9 deletions components/clarinet-cli/src/frontend/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use crate::deployments::{
self, check_deployments, generate_default_deployment, get_absolute_deployment_path,
write_deployment,
};
use crate::devnet::package as Package;
use crate::generate::{
self,
changes::{Changes, TOMLEdition},
};
use crate::integrate;
use crate::lsp::run_lsp;
use crate::runner::{run_scripts, DeploymentCache};
use crate::devnet::package as Package;

use clarinet_deployments::onchain::{
apply_on_chain_deployment, get_initial_transactions_trackers, update_deployment_costs,
Expand Down Expand Up @@ -115,7 +115,7 @@ enum Command {
Completions(Completions),
/// Subcommands for Devnet usage
#[clap(subcommand, name = "devnet")]
Devnet(Devnet)
Devnet(Devnet),
}

#[derive(Subcommand, PartialEq, Clone, Debug)]
Expand Down Expand Up @@ -167,7 +167,7 @@ enum Chainhooks {
enum Devnet {
/// Generate packaged deployment plan
#[clap(name = "package", bin_name = "package")]
Package(DevnetPackage)
Package(DevnetPackage),
}

#[derive(Parser, PartialEq, Clone, Debug)]
Expand Down Expand Up @@ -1436,13 +1436,12 @@ pub fn main() {
cmd.shell.generate(&mut app, &mut file);
println!("{} {}", green!("Created file"), file_name.clone());
println!("Check your shell's documentation for details about using this file to enable completions for clarinet");
},
}

Command::Devnet(subcommand) => match subcommand {
Devnet::Package(cmd) => {
Package::pack(cmd.package_file_name).expect("Could not execute the package command.")
}
}
Devnet::Package(cmd) => Package::pack(cmd.package_file_name)
.expect("Could not execute the package command."),
},
};
}

Expand Down Expand Up @@ -2087,4 +2086,4 @@ fn display_deploy_hint() {
yellow!("Find more information on the DevNet here: https://docs.hiro.so/clarinet/how-to-guides/how-to-run-integration-environment")
);
display_hint_footer();
}
}
2 changes: 1 addition & 1 deletion components/clarinet-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ pub mod deployments;
pub mod generate;
pub mod integrate;

pub mod devnet;
#[cfg(feature = "cli")]
pub mod frontend;
#[cfg(feature = "cli")]
pub mod lsp;
#[cfg(feature = "cli")]
pub mod runner;
pub mod devnet;

0 comments on commit d8f2f38

Please sign in to comment.