moonbit-argkit

    Small dependency-free command line argument parser for MoonBit.

    cli
    args
    parser
    moonbit
    Download zip
    Author
    Version
    0.1.0
    License
    MIT
    Last updated
    last month
    Downloads
    8

    #moonbit-argkit

    moonbit-argkit is a small command line argument parser written in MoonBit. It is meant for examples, teaching projects, and small CLI tools that need flags without pulling in a large framework.

    #Features

    • short flags: -v
    • long flags: --verbose
    • options with values: --output dist
    • inline option values: --output=dist
    • required option checks
    • default values
    • positional arguments
    • -- separator handling
    • schema validation and user-facing error reports
    • parse summaries for demos and small tools
    • typed values for integers, booleans, and enum-like choices
    • subcommand helpers
    • short flag bundles such as -abc
    • negative booleans such as --no-color
    • simple config/env layering helpers
    • shell completion, diagnostics, and Markdown/manpage rendering helpers
    • generated help text

    #Install

    After publishing, install with:

    moon add cauchyQ/moonbit-argkit@0.1.0

    For local development:

    moon check moon test moon run cmd/demo

    #Example

    let args = ["--input", "data.txt", "-v", "row1"]
    debug_inspect(has(args, "verbose", "v"), content="true")
    debug_inspect(value(args, "input", "i"), content="Some(\"data.txt\")")
    debug_inspect(value_or(args, "output", "o", "out.txt"), content="out.txt")
    debug_inspect(
    positionals(args, ["input"], ["i"], ["verbose"], ["v"]),
    content="[\"row1\"]",
    )

    Schema validation:

    let args = ["--input=data.txt", "-v", "row1"]
    debug_inspect(
    validation_report(
    args,
    ["input"],
    ["i"],
    ["input"],
    ["i"],
    ["verbose"],
    ["v"],
    ),
    content="\"ok\"",
    )
    debug_inspect(
    parse_summary(args, ["input"], ["i"], ["verbose"], ["v"]),
    content="[\"value:input=data.txt\", \"flag:verbose=true\", \"arg:row1\"]",
    )

    Help text:

    println(help_text(
    "demo",
    "read rows from an input file",
    ["input", "output"],
    ["i", "o"],
    ["input file", "output file"],
    ["verbose"],
    ["v"],
    ["print extra logs"],
    ))

    #License

    MIT

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io