Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ humantime.workspace = true
tokio.workspace = true
pluto-app.workspace = true
pluto-cluster.workspace = true
pluto-dkg.workspace = true
pluto-relay-server.workspace = true
pluto-tracing.workspace = true
pluto-core.workspace = true
Expand All @@ -35,6 +36,7 @@ serde_with = { workspace = true, features = ["base64"] }
rand.workspace = true
tempfile.workspace = true
reqwest.workspace = true
url.workspace = true

[dev-dependencies]
tempfile.workspace = true
Expand Down
7 changes: 7 additions & 0 deletions crates/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use clap::{Parser, Subcommand};

use crate::commands::{
create_enr::CreateEnrArgs,
dkg::DkgArgs,
enr::EnrArgs,
relay::RelayArgs,
test::{
Expand Down Expand Up @@ -51,6 +52,12 @@ pub enum Commands {
)]
Relay(Box<RelayArgs>),

#[command(
about = "Participate in a Distributed Key Generation ceremony",
long_about = "Participate in a distributed key generation ceremony for a specific cluster definition that creates distributed validator key shares and a final cluster lock configuration. Note that all other cluster operators should run this command at the same time."
)]
Dkg(Box<DkgArgs>),

#[command(
about = "Alpha subcommands provide early access to in-development features",
long_about = "Alpha subcommands represent features that are currently under development. They're not yet released for general use, but offer a glimpse into future functionalities planned for the distributed cluster system."
Expand Down
49 changes: 49 additions & 0 deletions crates/cli/src/commands/common.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//! Shared helpers for CLI commands.

use std::str::FromStr;

use libp2p::{Multiaddr, multiaddr};

/// Shared license notice shown by long-running commands.
pub const LICENSE: &str = concat!(
"This software is licensed under the Maria DB Business Source License 1.1; ",
"you may not use this software except in compliance with this license. You may obtain a ",
"copy of this license at https://github.com/NethermindEth/pluto/blob/main/LICENSE"
);

/// Console color selection for terminal logging.
#[derive(clap::ValueEnum, Clone, Copy, Debug, Default)]
pub enum ConsoleColor {
/// Automatically decide whether to use ANSI colors.
#[default]
Auto,
/// Always use ANSI colors.
Force,
/// Never use ANSI colors.
Disable,
}

/// Builds a console tracing configuration for CLI commands.
pub fn build_console_tracing_config(
level: impl Into<String>,
color: &ConsoleColor,
) -> pluto_tracing::TracingConfig {
let mut builder = pluto_tracing::TracingConfig::builder().with_default_console();

builder = match color {
ConsoleColor::Auto => builder.console_with_ansi(std::env::var("NO_COLOR").is_err()),
ConsoleColor::Force => builder.console_with_ansi(true),
ConsoleColor::Disable => builder.console_with_ansi(false),
};

// TODO: Handle loki config

// TODO: Handle log output path

builder.override_env_filter(level.into()).build()
}

/// Parses a relay string as either a relay URL or a raw multiaddr.
pub fn parse_relay_addr(relay: &str) -> std::result::Result<Multiaddr, libp2p::multiaddr::Error> {
multiaddr::from_url(relay).or_else(|_| Multiaddr::from_str(relay))
}
Loading
Loading