aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/new.rs
blob: 1c73bb81e5b4806c50dcc76d4b075d88119c1794 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//! Module implementing the `new` subcommand for generating a mnemonic for a new
//! hierarchical deterministic wallet.

use anyhow::Result;
use clap::Parser;
use hdwallet::mnemonic::{Language, Mnemonic};

#[derive(Debug, Parser)]
pub struct Options {
    /// The number of words for the mnemonic phrase.
    #[clap(short = 'n', long, default_value_t = 12)]
    length: usize,

    /// The language to generate the mnemonic for.
    #[clap(short, long, default_value_t)]
    language: Language,
}

pub fn run(options: Options) -> Result<()> {
    let mnemonic = Mnemonic::random(options.language, options.length)?;
    println!("{mnemonic}");
    Ok(())
}