Giter Site home page Giter Site logo

all-the-opts's Introduction

All The Opts

Wouldn't it be nice if didn't have to use getopt anymore? Well this still a work in progress so come back later and maybe your wish will come true...

pure-getopt which is designed to make GNU getopt's features available everywhere.

This is a wrapper to make it super easy to parse switches.

  • validates the inputs
  • auto-generate --help message
  • simple access to switch values
  • context aware arguments

Glossary

TODO: Write a glossary of terms

  • option
  • option_argument
  • operand
  • context
  • optional_argument
  • required_argument
  • no_argument

Functionality

  • ato_add: context, short, long, description (without last three, show). The order that you add is the order that it is evaluated.
  • ato_context: show set contexts or add a context
  • ato_description: set or show the description
  • ato_help: generate a help message
  • ato_operands: the things that are not arguments (what's the real name?)
  • ato_read: should read the option argument
  • ato_setup: do this first
  • ato_options: a list of the 'true' options

A Usage Example

    #!/usr/bin/env bash
    source ./all-the-opts.inc

    ato_description          "this is an example application"
    ato_context_add          "global"

    ato_add n name    "Set your name"
    ato_add v version "Display the version information"

    ato_setup $@

    ato_set --name "the default value of name"

    function version() {
        echo "version 1.0.0"
        return 0
    }

    function name() {
        name="$(ato_value --name)"
        echo "my name is ${name}"
        return 0
    }

    for arg in ${ato_options}; do
        case $arg in
            "-n"|"--name")
                ato_set --name $(ato_value ${arg})
                name
            ;;
            "-v"|"--version") version ;;
        esac
    done

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.