No description
Find a file
2023-01-01 08:32:56 -06:00
.github/workflows ci(docs): don't generate docs on non-code 2022-05-12 05:17:07 -05:00
examples chore: release 0.1.0 2022-05-12 04:39:27 -05:00
src fix: Added a test for and fixed remainingArgs() (#1) 2023-01-01 08:30:15 -06:00
tests fix: Added a test for and fixed remainingArgs() (#1) 2023-01-01 08:30:15 -06:00
.gitignore chore: release 0.1.0 2022-05-12 04:39:27 -05:00
blarg.nimble chore: update to 0.1.1 2023-01-01 08:32:56 -06:00
config.nims ci(docs): add doc generation action 2022-05-12 04:48:58 -05:00
LICENSE chore: release 0.1.0 2022-05-12 04:39:27 -05:00
README.md docs: add simple nimble install 2022-05-12 06:24:05 -05:00

blarg

A basic little argument parser for command-line tools.

Forked from cligen's parseopt3 module.

Requirements

Installation

$ nimble install blarg

or...

$ git clone https://github.com/squattingmonk/blarg.git
$ cd blarg
$ nimble install

Usage

In most cases, blarg can be used as a drop-in replacement for std/parseopt:

import blarg

for kind, key, val in getopt():
  case kind
  of cmdArgument:
    echo "got argument ", key
  of cmdShortOption, cmdLongOption:
    echo "got option ", key, " = ", val
  else:
    assert false # Cannot happen

For detailed usage, see the docs.

Features

  • Separator characters may be required or optional, and may be customized. If optional, short or long options that do not expect a value must be specified in shortNoVal and longNoVal respectively.
  • Supports operator characters before separators (e.g., --foo+=bar)
  • Supports -- and custom stop words, which treat any following options as arguments.
  • Stop words and long options that do not expect a value can be normalized (e.g., normalizing with strutils.normalize makes --foobar match --fooBar). The normalizing proc is optional and customizable, unlike cligen/parseopt3.

TODO

  • Add more examples for advanced usage