Skip to content

Commit

Permalink
Create cli.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Aug 11, 2024
1 parent f4929e5 commit 08ae48f
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions pi-nexus-blockchain/src/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// cli.rs (new)

use crate::blockchain::Blockchain;
use crate::transaction::Transaction;
use clap::{App, Arg};

fn main() {
let app = App::new("Blockchain CLI")
.version("1.0")
.author("Your Name")
.about("A command-line interface for the blockchain")
.arg(
Arg::with_name("command")
.required(true)
.index(1)
.help("The command to execute (e.g. 'create_transaction', 'add_block', 'get_chain')"),
);

let matches = app.get_matches();

let blockchain = Blockchain::new();

match matches.value_of("command").unwrap() {
"create_transaction" => {
// TO DO: implement create transaction logic
println!("Create transaction command");
}
"add_block" => {
// TO DO: implement add block logic
println!("Add block command");
}
"get_chain" => {
println!("Blockchain chain:");
for block in blockchain.chain {
println!("{:?}", block);
}
}
_ => println!("Invalid command"),
}
}

0 comments on commit 08ae48f

Please sign in to comment.