All Projects → Anvil → Bash Argsparse

Anvil / Bash Argsparse

Licence: wtfpl
An high level argument parsing library for bash

Programming Languages

shell
77523 projects
bash
514 projects

Projects that are alternatives of or similar to Bash Argsparse

Simplecli
Command Line Interface Library for Arduino
Stars: ✭ 135 (+5.47%)
Mutual labels:  command, library, line
Typin
Declarative framework for interactive CLI applications
Stars: ✭ 126 (-1.56%)
Mutual labels:  command, library, command-line-parser
Picocli
Picocli is a modern framework for building powerful, user-friendly, GraalVM-enabled command line apps with ease. It supports colors, autocompletion, subcommands, and more. In 1 source file so apps can include as source & avoid adding a dependency. Written in Java, usable from Groovy, Kotlin, Scala, etc.
Stars: ✭ 3,286 (+2467.19%)
Mutual labels:  bash-completion, completion, command-line-parser
google streetview
A command line tool and module for Google Street View Image API
Stars: ✭ 77 (-39.84%)
Mutual labels:  command, line
Neodoc
Beautiful, hand-crafted commandline interfaces for node.js
Stars: ✭ 221 (+72.66%)
Mutual labels:  command, line
gab-cmdline
A GABStudios Java library to help with command line parsing.
Stars: ✭ 12 (-90.62%)
Mutual labels:  command, line
unosolo
Work-in-progress Rust application that converts C++ header-only libraries to single self-contained headers.
Stars: ✭ 26 (-79.69%)
Mutual labels:  command, line
colortest
Quickly show all your terminal colors
Stars: ✭ 66 (-48.44%)
Mutual labels:  command, line
discord-message-handler
Message and command handler for discord.js bots and applications
Stars: ✭ 19 (-85.16%)
Mutual labels:  command, command-line-parser
ucollage
An extensible command line image viewer inspired by vim
Stars: ✭ 161 (+25.78%)
Mutual labels:  command, line
Fz
Cli shell plugin, the missing fuzzy tab completion feature of z jump around command.
Stars: ✭ 359 (+180.47%)
Mutual labels:  bash-completion, completion
Habitctl
Minimalist command line tool you can use to track and examine your habits.
Stars: ✭ 277 (+116.41%)
Mutual labels:  command, line
Complete
bash completion written in go + bash completion for go command
Stars: ✭ 761 (+494.53%)
Mutual labels:  bash-completion, completion
Yarn Completion
Bash completion for Yarn
Stars: ✭ 210 (+64.06%)
Mutual labels:  bash-completion, completion
SimpleCLI
Command Line Interface Library for Arduino
Stars: ✭ 197 (+53.91%)
Mutual labels:  command, line
Python
Python cheatsheet
Stars: ✭ 25 (-80.47%)
Mutual labels:  command, line
Gql
Very simple CLI for many GraphQL schemas in the cloud. Provides autocompletion for GraphQL queries
Stars: ✭ 101 (-21.09%)
Mutual labels:  command, line
Parser Php
Browser sniffing gone too far — A useragent parser library for PHP
Stars: ✭ 1,626 (+1170.31%)
Mutual labels:  library
Phplrt
PHP Language Recognition Tool
Stars: ✭ 127 (-0.78%)
Mutual labels:  library
Redux Unhandled Action
Redux middleware that logs an error to the console when an action is fired and the state is not mutated,
Stars: ✭ 125 (-2.34%)
Mutual labels:  library

bash-argsparse

An high level argument parsing library for bash.

Inspired, by the python argparse module, bash-argsparse purpose is to replace the option-parsing and usage-describing functions commonly rewritten in all scripts.

This library is implemented for GNU bash version >= 4.1. Prior versions of bash will fail at interpreting that code.

Online documentation

Doxygen documentation is available online here.

Tarballs

Though Bash Argsparse is hosted at github, you can download tarballs at the following URL: http://argsparse.livna.org/

RPMS

Though you can build your own package using the provided spec file, a bash-argsparse package is currently available in fedora repositories, for all releases from fedora 19 to rawhide. Ditto for RHEL/Centos 6 & 7, through the EPEL repository.

Features

The argsparse library offers to script developpers the following features:

  • Automatic help message generation
  • Simple option declarations
  • Different option types: simple, with value, with cumulative (uniq or not) values
  • User-input checkings (either by type, enumerations or custom checking)
  • Hook settings
  • Option properties making them excluding each other, aliasing other options, or (sic) non-optional.
  • Automatic bash completion generation.

Requirements, Bash settings

A basic argsparse run requires no external commands except the quite-common "getopt" command. Some argsparse-built-in type checkings may require some other (like "host" and "getent") but you do not have to use those types.

Argsparse relies on a lot of bash built-in commands ("printf", "[", "read", ...) and internal features such as arrays, associative arrays, extended (ksh-like) globbing. That's why the "extglob" shell option is automatically enabled and posix-mode is automatically disabled when loading the argsparse library.

The code has been tested on bash 4.1, 4.2 and 4.3 and is definitely not POSIX-compliant.

Compliance with the "nounset" and "failglob" bash settings is supported.

Content

  • argsparse.sh: the library.
  • tutorial: a bunch of small demonstration scripts for new users.
  • bash-argsparse.spec: a spec file to build RPM packages.
  • debian: the directory required to build deb packages.
  • Doxyfile: doxygen configuration file.
  • doxygen-bash.sed: bash-doxygen doxygen input filter.
  • unittest: a test script to validate most of argsparse features.

Testing

Here are the topics covered by scripts in tutorial directory:

  • 0-completion: An automatic bash completion demo for all other tutorial scripts. This script will spawn a preconfigured interactive bash.
  • 1-basics: Bash Argsparse basics
  • 2-values: Options accepting values
  • 3-cumulative-options: How to keep all user-given values
  • 4-types: Type-checking
  • 5-custom-types: User-defined types
  • 6-properties: Option properties
  • 7-value-checking: Advanced value checking using argsparse
  • 8-setting-hook: Changing the way options are set
  • 9-misc: Other misc argsparse features.

Invoke each script without parameter or with --help to obtain usage message.

Known limitations (or bugs)

  • You cannot have a short option without a long option.
  • Too few verifications about property values are made.
  • Compliance with errexit is not supported (yet).
  • Compliance with Non-bind versions of the "host" command has not been tested.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].