Skip to content
Verified Commit 85498176 authored by Matthew Clarkson's avatar Matthew Clarkson
Browse files

chore: add CLI `fetch` boilerplate

Sets up the harness for hosting nested CLI commands with `go-flags`[1].

Each command will be defined in a separate `go` file.

The structured logging is set up with the JSON outputter.

That can be controlled with `--log-level=<error|warn|info|debug>`

The `bazel-git fetch` usage mirrors an extreme subset of `git fetch` but includes
the `--reference` argument to provide references the tool can use to find a single
SHA when a server does not advertise the SHA.

The tool does nothing more that output the fetch arguments to the debug logging channel.

Try it out with:

    go run \
      ./cmd/bazel-git \
        --log-level debug \
        fetch \
        --reference one \
        --reference two \
        abc def

The output should be:

    {
      "time": "2024-02-02T14:35:14.478250053Z",
      "level": "DEBUG",
      "msg": "fetch",
      "FetchCommand": {
        "RecurseSubmodules": false,
        "References": [
          "one",
          "two"
        ],
        "Args": {
          "Remote": "abc",
          "Committish": [
            "def"
          ]
        }
      }
    }

[1]: https://pkg.go.dev/github.com/jessevdk/go-flags
parent 577d1004
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment