lib: Add x/lib/cmdline2 and x/ref/lib/v23cmd.

The cmdline2 package is very similar to the existing cmdline
package.  The main differences:
* Uses Runner interface, rather than Run func.
* Exposes Parse and ParseAndRun, rather than Init/Execute
* Passes *Env to runners, rather than *Command.

The purpose of these changes is to make it possible to get the
ordering of initialization right in our command line tools that
rely on v23.Init.  In particular, the previous Init/Execute API
was bad, since Execute perfomed both arg parsing and command
running.  That made it hard to inject special-purpose code,
e.g. for intializing the v23 context in tests.

The v23cmd package is a very small utility package that builds on
top of cmdline2 to make it really easy to add commands that need
a v23 context to be initialized.

The combination of these two packages lets us get rid of the
global gctx variable used in many of our cmdline tools.  I've
updated most tools that used gctx, to make sure the new mechanism
is really good enough for our needs.

I'll make another sweep in separate CLs to convert all other
tools over to cmdline2, and then have mechanical CLs to replace
cmdline with cmdline2.

Addresses some of vanadium/issues#407

MultiPart: 1/2

Change-Id: Ic277bbc2d930730117188afed891c9b5e26cd8e7
6 files changed
tree: 7c33d604907f1cdcc984d2b259460470261f6f8b
  1. buildinfo/
  2. cmdline/
  3. cmdline2/
  4. dbutil/
  5. host/
  6. metadata/
  7. netconfig/
  8. netstate/
  9. pubsub/
  10. textutil/
  11. toposort/
  12. vlog/
  13. .gitignore
  14. AUTHORS
  15. CONTRIBUTORS
  16. GO.PACKAGE
  17. LICENSE
  18. PATENTS
  19. README.md
  20. VERSION
README.md

This repository contains general purpose libraries used by the Vanadium project.