Giter Club home page Giter Club logo

bashargparser's Introduction

BashArgParser

BASIC DEMO USAGE

  • Get maunual page
XyZ@AsD-MacBook-Pro:bash_argparser$ ./usage_like_module.bash --man
--man		::	manual 
--example	::	example for usage,  2 par
--example2	::	other example for usage, 1 par
  • Input check - and manual
XyZ@AsD-MacBook-Pro:bash_argparser$ ./usage_like_module.bash asd
[!!!] valid arg not find, use --man for more info.
  • The right usage - paratemer inputs check
XyZ@AsD-MacBook-Pro:bash_argparser$ ./usage_like_module.bash --example val1 val2
example was called with parameters: val1 val2 
  • And the other input handling capabilities
XyZ@AsD-MacBook-Pro:bash_argparser$ ./usage_like_module.bash --example val1 val2 --example2 val1
example was called with parameters: val1 val2 
example was called with parameters: val1 

XyZ@AsD-MacBook-Pro:bash_argparser$ ./usage_like_module.bash --example val1 val2 --example2
--example2 arg required 1 parameter, 0 were given
[!!!] args error, use --man for more info.

XyZ@AsD-MacBook-Pro:bash_argparser$ ./usage_like_module.bash --example val1 --example2 val1
[!!!] args error, use --man for more info.

XyZ@AsD-MacBook-Pro:bash_argparser$ ./usage_like_module.bash --example2 val1
example was called with parameters: val1 

XyZ@AsD-MacBook-Pro:bash_argparser$ ./usage_like_module.bash --example2 val1 --example2 
--example2 arg required 1 parameter, 0 were given
[!!!] args error, use --man for more info.

XyZ@AsD-MacBook-Pro:bash_argparser$ ./usage_like_module.bash --example2 val1 --example val1 val2
example was called with parameters: val1 val2 
example was called with parameters: val1 

XyZ@AsD-MacBook-Pro:bash_argparser$ ./usage_like_module.bash --example2 val1 --example2 val11 val22
example was called with parameters: val11 

XyZ@AsD-MacBook-Pro:bash_argparser$ ./usage_like_module.bash --example2 val1 --example2 val112
example was called with parameters: val112 

XyZ@AsD-MacBook-Pro:bash_argparser$ ./usage_like_module.bash
XyZ@AsD-MacBook-Pro:bash_argparser$

To set your custom parameters edit:

bash_argparser/arg_pargser.bash file

  • At line: 12- 23
 12 # ------------------- SET ARG PARSER ----------------#
 13 function init() {
 14     #__________________________!!!!!!!!!___________________________#
 15     ########################## SET THESE ###########################
 16     known_args=("man" "debug" "example" "example2" "example3")                             # valid arg list - add ne    w args - call with -- expl: --man
 17     known_args_subs_pcs=(0 0 2 1 0)                                               # values for args - expl: --man ->     0, --example -> 1 etc.
 18     man_for_args=("--man\t\t::\tmanual"\                                        # add help text here
 19                   "--example\t::\texample for usage,  ${known_args_subs_pcs[2]} par"\
 20                   "--example2\t::\tother example for usage, ${known_args_subs_pcs[3]} par"\
 21                   "--example3\t::\tother example for usage, ${known_args_subs_pcs[4]} par")
 22     #______________________________________________________________#
 23     ################################################################

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.