drk/interactive: help print added

This commit is contained in:
skoupidi
2025-06-12 17:01:02 +03:00
parent 603ebe74f8
commit 4325d8019b
2 changed files with 15 additions and 3 deletions

View File

@@ -21,7 +21,7 @@ use linenoise_rs::{
linenoise_set_completion_callback, linenoise_set_hints_callback,
};
use darkfi::{system::StoppableTask, util::path::expand_path};
use darkfi::{cli_desc, system::StoppableTask, util::path::expand_path};
use crate::{
cli_util::{generate_completions, kaching},
@@ -29,11 +29,21 @@ use crate::{
};
// TODO:
// 1. add rest commands handling, along with their completions and hints.
// 1. add rest commands handling, along with their completions, hints and help message.
// 2. add input definitions, so you input from files not just stdin.
// 3. add output definitions, so you can output to files not just stdout.
// 4. create a transactions cache in the wallet db, so you can use it to handle them.
/// Auxiliary function to print the help message.
fn help() {
println!("{}", cli_desc!());
println!("Commands:");
println!("\thelp: Prints the help message");
println!("\tkaching: Fun");
println!("\tping: Send a ping request to the darkfid RPC endpoint");
println!("\tcompletions: Generate a SHELL completion script and print to stdout");
}
/// Auxiliary function to define the interactive shell completions.
fn completion(buf: &str, lc: &mut Vec<String>) {
if buf.starts_with("h") {
@@ -123,7 +133,7 @@ pub async fn interactive(drk: &Drk, history_path: &str) {
// Handle command
match parts[0] {
"help" => println!("hhhheeeelp"),
"help" => help(),
"kaching" => kaching().await,
"ping" => handle_ping(drk).await,
"completions" => handle_completions(&parts),
@@ -144,6 +154,7 @@ fn handle_completions(parts: &[&str]) {
if parts.len() != 2 {
println!("Malformed `completions` command");
println!("Usage: completions {{shell}}");
return
}
if let Err(e) = generate_completions(parts[1]) {

View File

@@ -68,6 +68,7 @@ const CONFIG_FILE_CONTENTS: &str = include_str!("../drk_config.toml");
// Dev Note: when adding/modifying args here,
// don't forget to update cli_util::generate_completions()
// and interactive::help().
#[derive(Clone, Debug, Deserialize, StructOpt, StructOptToml)]
#[serde(default)]
#[structopt(name = "drk", about = cli_desc!())]