Git Product home page Git Product logo

fanion's Introduction

Fanion

Exiguous command-line option parser.

Description

Fanion is a Common Lisp library for parsing command-line options. It parses them in the same way as OpenBSD getopt(3), but additionally supports long options, though currently with limitations (see Current issues).

This library is intentionally spartan in its functionality. It can parse options and nothing else; it cannot parse non-option arguments or subcommands, and it does not automatically generate usage of help messages. However, Fanion's option parsing should be flexible enough to cater to many use-cases thanks to its option-value reduction, which is modeled after Adopt's. See the manual for more information.

Fanion is currently under active development and its API is unstable, but it follows Semantic Versioning so breaking changes will be indicated by an appropriate bump in version number.

Installing

Fanion is not available on Quicklisp, so you will need to clone it to a location known to ASDF or Quicklisp:

git clone https://git.sr.ht/~paulapatience/fanion

Fanion has no dependencies beyond ASDF/UIOP. It is developed on SBCL, but should be compatible with any conventional Common Lisp implementation.

Examples

The Common Lisp files located in Fanion's scripts directory are good examples of Fanion being used in practice. The following is an extract of scripts/build-documentation.lisp:

(defparameter +options+
  (list
   (fanion:make-option 'format #\f nil
                       :value #'parse-format)
   (fanion:make-option 'help nil "help")
   (fanion:make-option 'output #\o nil
                       :value #'parse-output
                       :initial-value uiop:*stdout*)))

(fanion:parse +options+ (uiop:command-line-arguments))

See the documentation of FANION:MAKE-OPTION for further examples of its capabilities.

Documentation

Fanion is documented in its manual, which consists of an embellished version of this README supplemented with the API reference. It is available in Markdown form and in PDF form, the latter of which is distributed only alongside the release archive.

The manual is regenerated only at each release, so in order to consult the latest available version, you will need to build it manually:

make markdown pdf

Building the manual requires MGL-PAX and Pathname-Utils, and building the PDF manual further requires Pandoc, LuaLaTeX and suitable LaTeX packages.

Current issues

Long options are supported, but only as booleans. This will be corrected.

Also, no dedicated FANION-ERROR class exists for such errors as unrecognized options and missing values. An error class hierarchy may be added in the future.

See also

More fully featured alternatives to Fanion include:

The manual contains a more exhaustive list of similar libraries.

Acknowledgments

Fanion's option-value reduction, consisting of the VALUE, REDUCE and FINALLY arguments to FANION:MAKE-OPTION, is modeled after Adopt's, though in Adopt VALUE is named KEY and REDUCE is required.

License

This project is licensed under the MIT license (Expat).

Unless you explicitly state otherwise, any contribution intentionally submitted by you for inclusion in this project shall be licensed as above, without any additional terms or conditions.

fanion's People

Contributors

paulapatience avatar

Stargazers

Jorge Gomez avatar

Watchers

 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.