#help #parameters #command #cli #required #help-message #dashed

help_crafter

Simple help message generator without hussle

2 unstable releases

0.3.1 Jun 3, 2023
0.3.0 Jun 3, 2023
0.2.0 Jun 2, 2023
0.1.1 May 31, 2023
0.1.0 May 31, 2023

#1081 in Text processing

43 downloads per month

Apache-2.0 OR MIT

15KB
275 lines

Help Crafter

This crate provides simple method for generating help messages for your CLI application.

Quick Start

  1. command() for chaining commands to build help message
  2. build() for generate help message

Example

use help_crafter::enums::{DASHED, Parameter};
use help_crafter::HelpMessageBuilder;

   let help = HelpMessageBuilder::default()
   .command("i", "index", Parameter::NO, "index", DASHED::YES)
   .command(
       "k",
       "kill",
       Parameter::REQUIRED("sessions_id"),
       "the big brown fox jumps over the lazy dog the big brown fox",
       DASHED::YES,
   )
   .command(
       "",
       "rub",
       Parameter::OPTIONAL("something"),
       "rub something",
       DASHED::NO,
   )
   .command(
       "t",
       "",
       Parameter::REQUIRED("something"),
       "t something",
       DASHED::YES,
   )
   .command(
       "o",
       "",
       Parameter::OPTIONAL("something"),
       "o something",
       DASHED::NO,
   )
   .build();

lib.rs:

Help Crafter

This crate provides simple method for generating help messages for your CLI application.

Quick Start

  1. command() for chaining commands to build help message
  2. build() for generate help message

Example

use help_crafter::enums::{DASHED, Parameter};
use help_crafter::HelpMessageBuilder;

let help = HelpMessageBuilder::default()
        .command("i", "index", Parameter::NO, "index", DASHED::YES)
        .command(
            "k",
            "kill",
            Parameter::REQUIRED("sessions_id"),
            "the big brown fox jumps over the lazy dog the big brown fox",
            DASHED::YES,
        )
        .command(
            "",
            "rub",
            Parameter::OPTIONAL("something"),
            "rub something",
            DASHED::NO,
        )
        .command(
            "t",
            "",
            Parameter::REQUIRED("something"),
            "t something",
            DASHED::YES,
        )
        .command(
            "o",
            "",
            Parameter::OPTIONAL("something"),
            "o something",
            DASHED::NO,
        )
        .build();

Returns following message.

-i   --index                   index                                                      
-k   --kill    <sessions_id>   the big brown fox jumps over the lazy
                               dog the big brown fox
       rub     [something]     rub something                                              
-t             <something>     t something                                                
 o             [something]     o something   

No runtime deps