$ show cloudfoundry/cli
This is the official Cloud Foundry CLI (cf) version 9, a Go-based command-line tool for managing Cloud Foundry platforms. It provides a comprehensive set of commands for interacting with Cloud Controller (V2 and V3 APIs), UAA for authentication, networking policies, routing, and service brokers. The CLI supports application lifecycle management (push, scale, restart, logs), organization and space management, service instance and broker management, security groups, quotas, buildpacks, domains, routes, and plugins. The architecture follows a layered pattern: commands (in `command/v7/` and legacy `cf/commands/`) delegate to an actor layer (`actor/v7action/`, `actor/v7pushaction/`) which in turn uses API clients (`api/cloudcontroller/ccv3/`, `api/uaa/`, `api/cfnetworking/`, `api/router/`). HTTP clients are wrapped with middleware for authentication, retry, and logging. The codebase is heavily tested with unit tests (using counterfeiter fakes) and integration tests (Ginkgo/Gomega) that run against live or simulated CF environments. Key entry points include `main.go` which dispatches to either the V7 command parser or legacy V2 parser. The V7 commands are registered in `command/common/command_list_v7.go` and each command embeds a `BaseCommand` that provides shared setup (UI, config, actors). The push workflow is particularly complex, involving manifest parsing, resource matching, package creation, staging, and deployment via an event-driven pipeline in `actor/v7pushaction/`. External dependencies include Cloud Controller API, UAA, Log Cache, Networking Policy API, and Routing API. The CLI also supports a plugin system via RPC. The codebase is actively maintained with recent commits and CI workflows, though it carries legacy V2 code that is being gradually replaced by the V7 architecture.
The LLM identified 4 files worth highlighting for reuse:
Provides a `Sequentially` function that executes a slice of functions sequentially, collecting warnings and errors into a single result. This is a clean, reusable pattern for orchestrating multi-step operations where each step may produce warnings or errors, and the caller wants to accumulate all issues rather than fail fast. It is isolated (only imports standard library and a custom `Warnings` type) and can be extracted into any Go project needing sequential task execution with aggregated error handling.
Implements a generic pagination helper for Cloud Controller V3 API responses. It handles iterating over paginated results by following `next` links, with configurable per-page limits and early termination. The logic is self-contained and uses Go generics (type parameter `T any`), making it reusable for any paginated API that returns a list of resources with a `next` URL. Demonstrates clean separation of pagination concerns from resource-specific parsing.
A collection of custom types (NullString, NullInt, NullBool, OptionalString, FilteredString, etc.) that implement JSON marshal/unmarshal and flag parsing interfaces. These types handle the common pattern of optional/nullable fields in API responses and CLI flags, providing consistent zero-value handling and serialization. The package is fully isolated and can be reused in any Go project that needs robust nullable types with JSON support.
Defines a custom flag type for health check types (e.g., 'port', 'http', 'process') with validation, deprecation warnings for legacy values, and autocomplete support. It implements the `flags.Completer` and `flags.Unmarshaler` interfaces from the go-flags library. This pattern demonstrates how to create type-safe, user-friendly CLI flags with built-in validation and migration support, and can be adapted for any domain-specific flag type.