Skip to main content

forest/cli/subcommands/
shutdown_cmd.rs

1// Copyright 2019-2026 ChainSafe Systems
2// SPDX-License-Identifier: Apache-2.0, MIT
3
4use crate::cli::subcommands::prompt_confirm;
5use crate::rpc::{self, prelude::*};
6
7#[derive(Debug, clap::Args)]
8pub struct ShutdownCommand {
9    /// Assume "yes" as answer to shutdown prompt
10    #[arg(long)]
11    force: bool,
12}
13
14impl ShutdownCommand {
15    pub async fn run(self, client: rpc::Client) -> anyhow::Result<()> {
16        println!("Shutting down Forest node");
17        if !self.force && !prompt_confirm() {
18            println!("Aborted.");
19            return Ok(());
20        }
21        Shutdown::call(&client, ()).await?;
22        Ok(())
23    }
24}