How intersectmbo/cardano-cli works
Main Components
• CLI Application Core: At the heart is the “cardano-cli” executable (with entry point cardano-cli.hs). This layer is responsible for reading user input, parsing command-line options, and dispatching commands.
• Command Modules & Subsystems: Under the “src/Cardano/CLI” directory, there are many modules segmented by eras (Byron, EraBased, EraIndependent, and Compatible subdirectories). Each submodule handles specific commands such as genesis creation, key management, transaction building, governance actions, and delegation.
• Common Libraries & Utilities: Modules providing common types, error handling (in the “Type/Error” directories), JSON handling, IO utilities, and command-line parsing.
• Testing & Golden Files: A separate “test” hierarchy contains golden tests and a suite of test utilities that confirm the correctness of CLI commands. This is crucial for ensuring stability across protocol eras.
• Scripts and CI/CD Infrastructure: Directories such as “scripts/”, “.github/”, and “flake.nix” indicate an ecosystem for building, testing (e.g., via GitHub actions, CI scripts) and releasing the CLI application.
Component Relationships & Interactions
• Each command module interacts with core libraries for functionality such as key conversions, JSON rendering, IO operations, and error reporting. Show internal communication lines between “Command Modules” and “Utility & Library Modules.”
• Testing components “Golden Tests” and “CLI Test Libraries” feed input into the command modules to verify expected outputs. Illustrate a separate testing subsystem which “overrides” or “simulates” the command behavior.
• Scripts and CI/CD pipelines are external orchestrators that build, test, and deploy releases. They interface with the build system (Cabal, flake.nix) and trigger test suites.
• External blockchain or cardano‑node: Indicate that some commands (e.g., those sending transactions or querying the ledger) communicate with an external “Cardano Node” component.
Important Architectural Patterns
• Multi-Era Support and Abstraction: Distinct directories indicate different strategies for handling differences between blockchain eras. Use grouping to show “EraBased”, “EraIndependent”, and “Compatible” modules as layers on top of the common CLI core.
• Test-Driven Validation: The extensive golden tests and test libraries highlight the emphasis on regression testing and validation of command outputs. Represent this as an orthogonal testing layer.
Relevant Technologies & Tools
• Programming Language: Haskell (based on .cabal files and Haskell source code in the “src/” directories).
• Build System & Package Management: Cabal, flake.nix for Nix-based development.
• CI Systems: GitHub Actions, GitLab CI (as evidenced by workflow YAML files), and various shell scripts.
• Testing Frameworks: Golden tests, integration tests, and custom Haskell test libraries.
• External Interfacing: Cardano node and external command-line usage documentation.
Final Advice
• Decomposing the project into as many detailed components as possible, while maintaining a clear overall flow.