Skip to content

Yord/shargs-example-repl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pxi teaser

shargs-example-repl is a sample application of shargs 🦈.

See the shargs github repository for more details!

node version license PRs Welcome

Setup

$ git clone https://github.com/Yord/shargs-example-repl.git
$ cd shargs-example-repl
$ npm i
$ chmod +x ./repl

Example

This repository is a simple example of a program using the shargs command-line parser. The program can be found in the repl script.

Run the Example

Start the repl with:

$ ./repl

Help

If you type help, the following output is shown:

help                       Print usage documentation.                           
echo                       Echos a string.                                      
    <text>                 This text is echoed.                                 
case                       Transforms its argument into upper or lower case     
                           depending on the --mode.                             
    <text>                 This text is transformed into upper or lower case.   
    --mode=<upper|lower>   How to transform the text.                           

If you type help case, only the case usage documentation is printed:

case [<text>] [--mode]                                                          
                                                                                
<text>                                                                          
    This text is transformed into upper or lower case.                          
--mode=<upper|lower>                                                            
    How to transform the text.                                                  
                                                                                
Transforms its argument into upper or lower case depending on the --mode.       

You may even print usage documentation for several commands with help echo case:

echo [<text>]                                                                   
                                                                                
<text>                                                                          
    This text is echoed.                                                        
                                                                                
Echos a string.                                                                 

case [<text>] [--mode]                                                          
                                                                                
<text>                                                                          
    This text is transformed into upper or lower case.                          
--mode=<upper|lower>                                                            
    How to transform the text.                                                  
                                                                                
Transforms its argument into upper or lower case depending on the --mode.       

Executing Commands

Commands are executed as expected. E.g. case 'Foo Bar' --mode upper prints:

FOO BAR

While case 'Foo Bar' --mode lower prints:

foo bar

Error Messages

Error messages from the parser are printed in the REPL. E.g. if you use an unknown --mode in case, like in case 'Foo Bar' --mode camel:

ValueRestrictionsViolated: A value lies outside the allowed values of an option.

Foo Bar

Reporting Issues

Please report issues in the shargs tracker!

License

shargs-example-repl is MIT licensed.

About

shargs-example-repl is a sample application of shargs 🦈.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks