implement a cli module #85

Merged
PlexSheep merged 46 commits from feat/cli into devel 2024-07-09 18:12:24 +02:00
4 changed files with 10 additions and 10 deletions
Showing only changes of commit c9c835188b - Show all commits

View File

@ -173,7 +173,7 @@ impl VerbosityLevel {
} }
} }
/// get the [log::Level] for that VerbosityLevel /// get the [`log::Level`] for that `VerbosityLevel`
/// ///
/// This is the method for the [log] crate, which I use less often. /// This is the method for the [log] crate, which I use less often.
/// ///

View File

@ -5,7 +5,7 @@
//! output for CLI applications. //! output for CLI applications.
//! //!
//! Note that most of the utilities in this module are focused on communication with humans, not //! Note that most of the utilities in this module are focused on communication with humans, not
//! with machines. Consider evaluating [std::io::IsTerminal] before using colorful, dynamic and bordered //! with machines. Consider evaluating [`std::io::IsTerminal`] before using colorful, dynamic and bordered
//! printing. If you are talking to a machine, it might be useful to not add extra space, add a //! printing. If you are talking to a machine, it might be useful to not add extra space, add a
//! newline per output or even output JSON. An example that does this well is `ls`: //! newline per output or even output JSON. An example that does this well is `ls`:
//! //!
@ -50,12 +50,12 @@ use console::{style, Color};
/// ``` /// ```
#[inline] #[inline]
pub fn blockprint(content: impl ToString, color: Color) { pub fn blockprint(content: impl ToString, color: Color) {
println!("{}", blockfmt(content, color)) println!("{}", blockfmt(content, color));
} }
/// Formats content with a simple border around it /// Formats content with a simple border around it
/// ///
/// This function is a convenience wrapper around [blockfmt_advanced] with preset values for /// This function is a convenience wrapper around [`blockfmt_advanced`] with preset values for
/// border style, content arrangement, and cell alignment. It automatically formats the content /// border style, content arrangement, and cell alignment. It automatically formats the content
/// with a border as large as possible and centers the content. The resulting cell is colored in /// with a border as large as possible and centers the content. The resulting cell is colored in
/// the specified color. /// the specified color.

View File

@ -9,10 +9,10 @@ use super::Repl;
use embed_doc_image::embed_doc_image; use embed_doc_image::embed_doc_image;
/// [clap] help template with only usage and commands/options /// [clap] help template with only usage and commands/options
pub const REPL_HELP_TEMPLATE: &str = r#"{usage-heading} {usage} pub const REPL_HELP_TEMPLATE: &str = r"{usage-heading} {usage}
{all-args}{tab} {all-args}{tab}
"#; ";
use clap::{Parser, Subcommand}; use clap::{Parser, Subcommand};
use dialoguer::{BasicHistory, Completion}; use dialoguer::{BasicHistory, Completion};
@ -186,11 +186,11 @@ where
buf.push( buf.push(
format!("{c:?}") format!("{c:?}")
.split_whitespace() .split_whitespace()
.map(|e| e.to_lowercase()) .map(str::to_lowercase)
.next() .next()
.unwrap() .unwrap()
.to_string(), .to_string(),
) );
} }
trace!("commands: {buf:?}"); trace!("commands: {buf:?}");
buf buf

View File

@ -22,7 +22,7 @@ use clap::{Parser, Subcommand};
/// Common Trait for repl objects /// Common Trait for repl objects
/// ///
/// Unless you want to implement custom features (not just commands), just use [DefaultRepl]. /// Unless you want to implement custom features (not just commands), just use [`DefaultRepl`].
pub trait Repl<C>: Parser + Debug pub trait Repl<C>: Parser + Debug
where where
C: Debug, C: Debug,
@ -39,6 +39,6 @@ where
/// ///
/// This should be used at the start of your loop. /// This should be used at the start of your loop.
/// ///
/// Note that the help menu is an Error: [clap::error::ErrorKind::DisplayHelp] /// Note that the help menu is an Error: [`clap::error::ErrorKind::DisplayHelp`]
fn step(&mut self) -> Result<(), ReplError>; fn step(&mut self) -> Result<(), ReplError>;
} }