GithubHelp home page GithubHelp logo

docoptsh's Introduction

Docoptsh

CircleCI

A command-line argument parser written in pure Bash, for size-constrained systems, such as Android devices running Termux, Windows as a secondary OS using the Subsystem for Linux or minimal Docker containers.

It implements a subset of the docopt language, which should be enough for most scripting needs.

Examples

Given the documentation below...

Ship helpers

Usage:
  ship [options] move <x> <y>
  ship [fast] create
  ship paint (green|red)

Options:
  -f --force             Ignore ongoing movement
  -t --target <target>   Ship-id [default: 0] 

...the following script calls are valid and will set the variables accordingly:

ship move 10 30
ship create
ship fast create
ship paint red
ship -ft=2 10 30
ship -f --target 2 10 30

Real-world examples can be found in my dotfiles.

Usage

./docoptsh -h "Script description\nUsage: ..." : move -t=2 10 30

Unsupported syntax

As of now, most nested structures won't work, such as:

ship [--shape <shape>]
ship (fast|[<style>])

Also, variadic arguments won't work as well:

ship destroy -- <ids>...

Alternatives

If the system running the script has Python installed, such as a batteries included, personal computer, you probably want to use the Python-based docopt parser.

Otherwise, if compiling and using a binary for a given OS and processor architecture isn't a concern, you can use the Go-based docopt parser.

docoptsh's People

Contributors

denisidoro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.