Command Argument Library repositories at ouser4629 to be deleted

Within a few days all public repositories at ouser4629 , including cmd-arg-lib 0.4.x, will be made private, and eventually deleted.

cmd-arg-lib 0.5.0 will be released soon, in a new Github account: psummerland2.

Version 0.5.0

  • consists of separate modules for easier maintenance and customization
  • is completely open source - no binaries
  • requires macOS v12, not macOS 26
  • has a new struct-based API, in addition to its macro-based API
  • has new features and better examples

The modules are:

  • CmdArgLib - core
  • CmdArgLibMacros - macros-based API
  • CmdArgLibCommandSpec - struct-based API
  • CmdArgLibHelpScreen - composable help screen
  • CmdArgLibManpage - composable manual pages
  • CmdArgLibCompletions - completion scrips
  • CmdArgLibTestSupport - support for testing against command tool output

The two API's are functionally the same.

The macro-based API is basically the same as for earlier versions. It gleans info from the annotated command function's signature.

import CmdArgLib
import CmdArgLibMacros
import CmdArgLibHelpScreen

@main
struct Main{
    @MainFunction
    static public func repeatM(
        u: Flag = false,
        count: Int = 1,
        phrase: String,
        h__help: MetaFlag = MetaFlag(helpElements: helpLayout)) throws
    { ... }

   private static let helpLayout: [ShowElement] = [ ... ]
}

The struct-based API gleans info from stored properties in a struct, augmented by a static configuration property. It does not depend on macros or property wrappers.

import CmdArgLib
import CmdArgLibCommandSpec
import CmdArgLibHelpScreen

@main
struct Main: CommandSpec {
    var u: Bool = false
    var phrase: String? = nil
    var count: Int = 1
    var h__help: MetaFlag = MetaFlag(helpElements: helpLayout)

    func run(state: [Void]) throws -> [Void] { ... }

    static let configuration = CommandNodeConfiguration<Void>(
        commandName: "repeat-s",
    )

    private static let helpLayout: [ShowElement] = [ ... ]
}

The conforming struct provides a static main() function and a static commandNode property that returns a CommandNode, with a run method that can be called directly or recursively by parent CommandNodes. Command nodes pass state to child nodes which is why the run method has a state parameter.