Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software:2222/vole.git

A free and open-source forge that lives in your Git repo.

#39

Take --config anywhere in a resource command, not just after it

merged · by keenan 13d ago · merged into main at 0f8054ad by keenan 13d ago

keenan opened this 13d ago

vole admin --config P account list exits 129 with unknown account subcommand "--config". The admin namespace peels --config out of the command line — it belongs to the namespace, not the resource — and then handed it back ahead of the subcommand. Every resource command reads its subcommand from the first argument, so the flag became the subcommand.

The pre-admin spellings had the same defect: vole account --config P list broke identically, because the alias dispatches straight into the same function.

What changed

The three resource commands that take a subcommand (account, repo, acl) now peel the config global off the front of their own arguments before reading the subcommand:

cfgPath, args, err := peelConfig(args)   // before args[0] is the subcommand
...
if f.cfgPath == "" { f.cfgPath = cfgPath }

That is the second option in the issue, and it fixes more than the reported line:

  • vole admin --config P account list — the bug.
  • vole account --config P list — the alias spelling, broken the same way.
  • vole admin account list --config P — unchanged, still works, and wins when both are given because it is the later value.

init, gc, and index need no change: they parse flags over the whole argument list and have no subcommand to protect.

With the flag now accepted on either side, the flag parser’s documented rule (“options may appear before or after arguments”) is true for these commands too, so the workaround paragraph in CONTRIBUTING.md is gone and docs/cli.md records the placement rule next to the --config examples.

Tests

cmd/vole/admin_test.go builds two instances with different accounts, so a listed name proves the flag was applied rather than merely accepted, then checks each placement: before the resource, after the subcommand, --config=…, -c …, -c…, and the legacy alias spelling — plus repo list and acl show <repo>, which the issue’s acceptance criteria name. VOLE_CONFIG is checked with no flag at all.

The test is a real regression test: with the four source files reverted it fails on the first three placements with unknown account subcommand "--config", and passes with the fix.

Checks

gofmt, go vet ./..., go test ./..., vole workflow check, and vole workflow run verify (7 steps, -race) all pass.

Closes #01M5XCJVEZAX8SQNQMDZZF9FRJ

Discussion (0)

No discussion yet.