# `NBPR.BrPackage`
[🔗](https://github.com/jimsynz/nbpr/blob/v0.2.0/lib/nbpr/br_package.ex#L1)

The macro every NBPR package uses.

## Daemonless example

    defmodule NBPR.Jq do
      use NBPR.BrPackage,
        version: 1,
        br_package: "jq",
        description: "Lightweight JSON processor",
        homepage: "https://jqlang.github.io/jq/",
        build_opts: [
          oniguruma: [
            type: :boolean,
            default: true,
            br_flag: "BR2_PACKAGE_JQ_ONIGURUMA",
            doc: "Enable Oniguruma regex support"
          ]
        ]
    end

## Daemon-bearing example

    defmodule NBPR.Dnsmasq do
      use NBPR.BrPackage,
        version: 1,
        br_package: "dnsmasq",
        description: "Lightweight DHCP/DNS server",
        daemons: [
          dnsmasq: [
            path: "/usr/sbin/dnsmasq",
            opts: [
              config_file: [type: :string, required: true, flag: "--conf-file"],
              keep_in_foreground: [type: :boolean, default: true, flag: "--keep-in-foreground"]
            ]
          ]
        ]
    end

Each declared daemon emits a nested module (`NBPR.Dnsmasq.Dnsmasq` above) with
`child_spec/1`, `start_link/1`, and `argv/1`. Users add the daemon module to
their own supervision tree.

## Argv assembly

The default argv builder zips each runtime opt with its declared `:flag`:
booleans emit the flag if `true` (nothing if `false`); other values emit
`[flag, to_string(value)]`. For daemons whose argv has subcommands or
positional arguments, override with `argv_template:` in the daemon spec —
any MFA tuple `{module, fun, extra_args}` whose function returns a list of
strings.

# `default_argv`

```elixir
@spec default_argv(
  keyword(),
  %{required(atom()) =&gt; String.t()}
) :: [String.t()]
```

Default argv builder. Zips each opt with its `:flag` extension; booleans emit
the flag-only form, other values emit `[flag, to_string(value)]`, opts without
a `:flag` mapping are dropped.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
