Skip to content

Conversation

@YOU54F
Copy link
Member

@YOU54F YOU54F commented Oct 8, 2025

📝 Summary of Changes

Changes proposed in this pull request:

  • Modifications to allow pact_mock_server_cli to be consumed as a library pact_mock_server_cli so it can be composed in other clis

⚠️ Items of Note

Part of a series of pull requests

💁 Example

Composed cli: https://github.com/YOU54F/pact_cli/blob/259a268dd9e7fa48ad03c088f7244af7a4c89493/src/cli.rs#L11-L29

pub fn build_cli() -> Command {
    let app = Command::new("pact_cli")
        .about("A pact cli tool")
        .subcommand(
            pact_broker_cli::cli::pact_broker_client::add_pact_broker_client_command()
                .name("pact-broker")
                .subcommand(add_standalone_broker_subcommand())
                .subcommand(add_docker_broker_subcommand()),
        )
        .args(pact_broker_cli::cli::add_logging_arguments())
        .subcommand(
            pact_broker_cli::cli::pactflow_client::add_pactflow_client_command().name("pactflow"),
        )
        .subcommand(add_completions_subcommand())
        .subcommand(pact_plugin_cli::Cli::command().name("plugin"))
        .subcommand(pact_mock_server_cli::setup_args().name("mock"))
        .subcommand(pact_verifier_cli::args::setup_app().name("verifier"))
        .subcommand(pact_stub_server_cli::build_args().name("stub"));
    app
}

Cargo toml: https://github.com/YOU54F/pact_cli/blob/259a268dd9e7fa48ad03c088f7244af7a4c89493/Cargo.toml#L67-L71

pact-stub-server = { version = "*", git = "https://github.com/YOU54F/pact-stub-server.git", branch = "feat/cli_as_lib"}
pact_mock_server_cli = { version = "2.0.0-beta.1", git = "https://github.com/YOU54F/pact-core-mock-server.git", branch = "feat/cli_as_lib"}
pact-plugin-cli = { version = "*", git = "https://github.com/YOU54F/pact-plugins", branch = "feat/cli_as_lib"}
pact_verifier_cli = { version = "*",  git = "https://github.com/YOU54F/pact-reference", branch = "feat/cli_as_lib"}
pact-broker-cli = { version = "*", git = "https://github.com/YOU54F/pact-broker-cli", branch = "main"}

🔨 How To Test

git clone [email protected]:YOU54F/pact_cli.git
cd pact_cli
git checkout multi-cli
RUSTFLAGS=-Awarnings cargo run -q --

output

A pact cli tool

Usage: pact_cli [OPTIONS] [COMMAND]

Commands:
  pact-broker  
  pactflow     
  completions  Generates completion scripts for your shell
  plugin       CLI utility for Pact plugins
  mock         Standalone Pact mock server
  verifier     Standalone pact verifier for provider pact verification
  stub         Pact Stub Server 0.6.3
  help         Print this message or the help of the given subcommand(s)

Options:
      --log-level <LEVEL>  Set the log level (none, off, error, warn, info, debug, trace) [default: off] [possible values: off, none, error, warn, info, debug, trace]
  -h, --help               Print help

usage

Standalone Pact mock server

Usage: pact_cli mock [OPTIONS] [COMMAND]

Commands:
  start            Starts the master mock server
  list             Lists all the running mock servers
  create           Creates a new mock server from a pact file
  verify           Verify the mock server by id or port number, and generate a pact file if all ok
  shutdown         Shutdown the mock server by id or port number, releasing all its resources
  shutdown-master  Performs a graceful shutdown of the master server (displayed when it started)
  help             Print this message or the help of the given subcommand(s)

Options:
      --help                 Print help and exit
      --log-level <LEVEL>    Set the log level (none, off, error, warn, info, debug, trace) [default: off] [possible values: off, none, error, warn, info, debug, trace]
  -v, --version              Print version information and exit
  -p, --port <port>          port the master mock server runs on (defaults to 8080)
  -h, --host <host>          hostname the master mock server runs on (defaults to localhost)
  -l, --loglevel <loglevel>  Log level for mock servers to write to the log file (defaults to info) [possible values: error, warn, info, debug, trace, none]
      --no-term-log          Turns off using terminal ANSI escape codes
      --no-file-log          Do not log to an output file

@YOU54F
Copy link
Member Author

YOU54F commented Oct 22, 2025

todo - rename bin to pact-mock-server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant