Search by

rmb32 / barnark-cli

rogerbarnfather

The command-line delivery mechanism for Barnark — the template commands (list, new, clone, copy, delete, offers, check, add-folder, change-meaning).

Package info

bitbucket.org/rmb32/barnark-cli/

Homepage

pkg:composer/rmb32/barnark-cli

Statistics

Installs: 182

Dependents: 0

Suggesters: 0

v0.1.1 2026-11-11 11:56 UTC

This package is auto-updated.

Last update: 2026-11-11 15:01:11 UTC


README

Early, version 0.x. Not ready for real projects yet; the minor version is the breaking one.

Part of Barn.

The barnark command: clone an architecture template into your project under a name you give, make a folder to it, and check that the folder keeps to it. Built on Barnark.

Requirements

  • PHP 8.5+

Installation

composer global require rmb32/barnark-cli     # once, for every project
# or per project
composer require --dev rmb32/barnark-cli

Usage

barnark init                                             # make a barn here (the .barn/ folder) if there is none
barnark template:list                                    # the bound template, your own and the shipped ones
barnark template:clone "Domain Driven Design" Shop ./src  # clone the template as Shop and make src/
barnark template:check                                   # check the bound folder against its template
barnark template:offers src/Context                     # what can be created in this folder?
barnark template:new Context Billing src/Context         # add a member to the template and make its folders
barnark template:add-folder src/Docs "Design notes."      # add a folder of your own to the template, or take one in
barnark template:change-meaning src/Docs "Notes."         # change what a folder of the template means
barnark template:copy Shop Invoicing                     # copy the bound template into a new one of your own
barnark template:delete Invoicing                        # delete the copy
barnark gui                                              # serve the browser UI and open it (needs rmb32/barnark-gui)

A project has one bound template, bound to one folder. template:clone makes them together: it copies a template, shipped or one of your own, under the name you give it, and makes a folder for each member it has. The copy is tied to nothing, so a later change to the template it came from never reaches it. A project that has its bound template already refuses another. The name can't be one the project already has, or a shipped template's name, ignoring case; --dry-run checks the template, the name and the target, and prints the folders it would make. The folder above the new one must exist.

Your own templates come from template:copy, which copies a shipped template, one of yours or the bound template, members included. Shipped templates are read-only. Deleting one of your own asks first, since only git brings it back (-n goes ahead without asking).

The project remembers which folder its template is bound to in .barn/barnark/tracked-folders.json, and keeps each template, bound or not, with every revision, in .barn/barnark/catalogue/. Don't edit those files by hand: a template changed outside Barnark can't be read. A tracked-folders.json binding several folders is refused, with the file's path, until you delete it or move it away.

The barn

Barnark keeps its records only in a barn: the project's .barn/ folder, which every Barn tool shares. barnark init makes one in the current folder (and asks first inside another barn; -n refuses there unless you pass --separate-barn). With no barn, every template: command refuses and writes nothing, and barnark gui serves a page that offers to make one. Each template: command prints the barn's root first, and works from any folder inside it. Folder paths are relative to the barn's root. The bound folder can be named the way the GUI shows it, from the root (barnark template:check /src), from any folder inside the barn.

cd src/Context
barnark template:new Context Shipping .   # added to the template in .barn/barnark/catalogue/
barnark template:check                    # checks the barn's bound folder

template:check checks a real project's own contexts, features and aggregates where they actually are. A template's parts are the folders it names itself; its slots are what your own folders fill. Where the template leaves a folder no choice (every folder in Context/ is a Context), it is checked as filling that slot, and that works for an explicit template and directory too. A member added with template:new or the GUI is in the template, so if its folder is deleted by hand the check reports it as missing. Files are never checked: a template says only what folders there are.

The same template says what may be created in a folder, which is what template:offers reports and template:new acts on:

$ barnark template:offers src/Context/Billing/Domain
 ----------- ----------- -------------------------------------------------------------
  Slot        Key         Create it with
 ----------- ----------- -------------------------------------------------------------
  Aggregate   Aggregate   barnark template:new Aggregate <name> src/Context/Billing/Domain
 ----------- ----------- -------------------------------------------------------------

$ barnark template:new Aggregate Invoice src/Context/Billing/Domain

template:new adds a member you name to the template, as a new revision, then makes its folder with whatever fixed structure the slot carries — a Context arrives with its Domain, Application, Infrastructure and PublicApi. Barnark adds .gitkeep to empty folders so git can track them. A member already in the template is refused.

A folder of your own goes into the template with template:add-folder <path> <meaning>: a new revision with the folder in it, saying what belongs there, then the folder. A folder already made by hand is kept as it is, so this is how one template:check reports as unexpected is taken in. template:change-meaning <path> <meaning> changes what a folder of the template, or the bound folder itself, means. A collection holds only members, so a folder inside one is refused, and so is a folder the template uses in several places, since changing it would change it in each.

A folder offers nothing when it holds only fixed parts (the root of a Domain Driven Design folder is all Kernel/Transport/Context), or when the template names nothing inside it, or when it sits outside the template.

Run barnark <command> --help for every option.

CommandPurpose
initMake a barn in the current folder, or name the one it is the root of
template:listList the bound template, your own and the shipped ones
template:cloneClone a template into the project under a name you give, and make its folder
template:checkCheck the bound folder against its template, or a directory against a shipped template
template:copyCopy a template into a new one of your own
template:deleteDelete one of your templates, with every revision
template:offersList the slots a folder's template says can be filled inside it
template:newAdd a member the folder offers, under a name you give, to the template and the disk
template:add-folderAdd a folder of your own to the template, or take in one made by hand
template:change-meaningChange what a folder of the template means

Related packages

  • Barnark — the core library and template catalogue.
  • Barnark GUI — the same operations in a browser.
  • Barntree — what the templates are written as.

More docs

Internals · History · Known issues

License

Proprietary. See LICENSE. Copyright (c) Roger Barnfather.