forc_node/
cmd.rs

1use std::net::IpAddr;
2
3use crate::{
4    consts::{DEFAULT_PEERING_PORT, DEFAULT_PORT},
5    ignition::cmd::IgnitionCmd,
6    local::cmd::LocalCmd,
7    testnet::cmd::TestnetCmd,
8};
9use clap::{Parser, Subcommand};
10
11#[derive(Debug, Parser)]
12#[clap(name = "forc node", version)]
13/// Forc node is a wrapper around fuel-core with sensible defaults to provide
14/// easy way of bootstrapping a node for local development, testnet or mainnet.
15pub struct ForcNodeCmd {
16    /// Print the fuel-core command without running it.
17    #[arg(long)]
18    pub dry_run: bool,
19    #[command(subcommand)]
20    pub mode: Mode,
21}
22
23#[derive(Subcommand, Debug)]
24pub enum Mode {
25    /// Starts a local node for development purposes.
26    Local(LocalCmd),
27    /// Starts a node that will connect to latest testnet.
28    Testnet(TestnetCmd),
29    /// Starts a node that will connect to ignition network.
30    Ignition(IgnitionCmd),
31}
32
33/// Set of shared node settings, specifically related to connections.
34#[derive(Parser, Debug, Clone)]
35pub struct ConnectionSettings {
36    #[clap(long)]
37    pub peer_id: Option<String>,
38    #[clap(long)]
39    pub secret: Option<String>,
40    #[clap(long)]
41    pub relayer: Option<String>,
42    #[clap(long, default_value = "0.0.0.0")]
43    pub ip: IpAddr,
44    #[clap(long, default_value_t = DEFAULT_PORT, value_parser = clap::value_parser!(u16).range(1..=65535))]
45    pub port: u16,
46    #[clap(long, default_value_t = DEFAULT_PEERING_PORT, value_parser = clap::value_parser!(u16).range(1..=65535))]
47    pub peering_port: u16,
48}