Command Argument Library - Refactored

As some of you might know, I’ve been working on a Swift command-line argument library called Command Argument Library (CAL).

After a few false starts — for which I apologize — CAL has evolved significantly since my original post and has now reached a stable beta stage.

Features

  • Automatic, type-safe parsing of CLI arguments
    • Consistent, predictable, Swift-based CLI syntax
    • Flags
    • Strings, Ints, Doubles (including negatives)
    • String-backed enums
    • Custom types
    • Arrays, optionals, variants
    • Default values
    • All enabled by one line of code, a peer macro
  • Separation of concerns
    • Definition of CLI syntax via function signatures
    • Generated run functions for parsing CLI arguments and invoking program logic
    • Generated context functions for documentation of CLI syntax and program logic
  • Compile-time error reporting
    • Duplicate short label names
    • Meta-flag parameters without default values
    • Parameter types not allowed by the library's macros
    • and more
  • Run-time error reporting
    • Reusable error screens (for parser and user code)
    • Multiple syntax errors reported in a single pass
  • Meta-services
    • Composable help screens (not template-based)
    • Manual page generation with full mdoc support
  • Hierarchical command structures
    • State propagation
    • Tree diagram generation
  • Completion script generation for zsh and fish

Repository:

Command Argument Library

7 Likes