Skip to content

Commit

Permalink
chore: make the provider and consumer name parameters singular
Browse files Browse the repository at this point in the history
  • Loading branch information
rholshausen committed Oct 24, 2022
1 parent 5398be5 commit ab2c414
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 81 deletions.
109 changes: 44 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,71 +22,50 @@ pact files.
The pact stub server is bundled as a single binary executable `pact-stub-server`. Running this without any options displays the standard help.

```console
./pact-stub-server v0.5.0
Pact Stub Server

USAGE:
pact-stub-server [OPTIONS]

OPTIONS:
-b, --broker-url <broker-url>
URL of the pact broker to fetch pacts from [env: PACT_BROKER_BASE_URL=]

--consumer-names <consumer-names>...
Consumer names to use to filter the Pacts fetched from the Pact broker

--cors-referer
Set the CORS Access-Control-Allow-Origin header to the Referer

-d, --dir <dir>
Directory of pact files to load (can be repeated)

-e, --extension <ext>
File extension to use when loading from a directory (default is json)

--empty-provider-state
Include empty provider states when filtering with --provider-state

-f, --file <file>
Pact file to load (can be repeated)

-h, --help
Print help information

--insecure-tls
Disables TLS certificate validation

-l, --loglevel <loglevel>
Log level (defaults to info) [possible values: error, warn, info, debug, trace, none]

-o, --cors
Automatically respond to OPTIONS requests and return default CORS headers

-p, --port <port>
Port to run on (defaults to random port assigned by the OS)

--provider-names <provider-names>...
Provider names to use to filter the Pacts fetched from the Pact broker

--provider-state-header-name <provider-state-header-name>
Name of the header parameter containing the provider state to be used in case multiple
matching interactions are found

-s, --provider-state <provider-state>
Provider state regular expression to filter the responses by

-t, --token <token>
Bearer token to use when fetching pacts from URLS or Pact Broker

-u, --url <url>
URL of pact file to fetch (can be repeated)

--user <user>
User and password to use when fetching pacts from URLS or Pact Broker in user:password
form

-v, --version
Print version information
pact-stub-server
Pact Stub Server 0.5.2

Usage: pact-stub-server [OPTIONS]

Options:
-l, --loglevel <loglevel>
Log level (defaults to info) [default: info] [possible values: error, warn, info, debug, trace, none]
-f, --file <file>
Pact file to load (can be repeated)
-d, --dir <dir>
Directory of pact files to load (can be repeated)
-e, --extension <ext>
File extension to use when loading from a directory (default is json)
-u, --url <url>
URL of pact file to fetch (can be repeated)
-b, --broker-url <broker-url>
URL of the pact broker to fetch pacts from [env: PACT_BROKER_BASE_URL=]
--user <user>
User and password to use when fetching pacts from URLS or Pact Broker in user:password form
-t, --token <token>
Bearer token to use when fetching pacts from URLS or Pact Broker
-p, --port <port>
Port to run on (defaults to random port assigned by the OS)
-o, --cors
Automatically respond to OPTIONS requests and return default CORS headers
--cors-referer
Set the CORS Access-Control-Allow-Origin header to the Referer
--insecure-tls
Disables TLS certificate validation
-s, --provider-state <provider-state>
Provider state regular expression to filter the responses by
--provider-state-header-name <provider-state-header-name>
Name of the header parameter containing the provider state to be used in case multiple matching interactions are found
--empty-provider-state
Include empty provider states when filtering with --provider-state
--consumer-name <consumer-name>
Consumer name to use to filter the Pacts fetched from the Pact broker (can be repeated)
--provider-name <provider-name>
Provider name to use to filter the Pacts fetched from the Pact broker (can be repeated)
-v, --version
Print version information
-h, --help
Print help information
```

## Options
Expand Down
26 changes: 14 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
//! Name of the header parameter containing the provider state to be used in case multiple matching interactions are found
//! --empty-provider-state
//! Include empty provider states when filtering with --provider-state
//! --consumer-names <consumer-names>
//! Consumer names to use to filter the Pacts fetched from the Pact broker
//! --provider-names <provider-names>
//! Provider names to use to filter the Pacts fetched from the Pact broker
//! --consumer-name <consumer-name>
//! Consumer name to use to filter the Pacts fetched from the Pact broker (can be repeated)
//! --provider-name <provider-name>
//! Provider name to use to filter the Pacts fetched from the Pact broker (can be repeated)
//! -v, --version
//! Print version information
//! -h, --help
Expand Down Expand Up @@ -184,10 +184,10 @@ fn pact_source(matches: &ArgMatches) -> Vec<PactSource> {
sources.push(PactSource::Broker {
url: url.to_string(),
auth,
consumers: matches.get_many::<String>("consumer-names")
consumers: matches.get_many::<String>("consumer-name")
.map(|v| v.map(ToString::to_string)
.collect_vec()).unwrap_or_default(),
providers: matches.get_many::<String>("provider-names")
providers: matches.get_many::<String>("provider-name")
.map(|v| v.map(ToString::to_string)
.collect_vec()).unwrap_or_default()
});
Expand Down Expand Up @@ -354,18 +354,20 @@ fn build_args() -> Command {
.requires("provider-state")
.action(ArgAction::SetTrue)
.help("Include empty provider states when filtering with --provider-state"))
.arg(Arg::new("consumer-names")
.long("consumer-names")
.arg(Arg::new("consumer-name")
.long("consumer-name")
.alias("consumer-names")
.requires("broker-url")
.action(ArgAction::Append)
.value_parser(clap::builder::NonEmptyStringValueParser::new())
.help("Consumer names to use to filter the Pacts fetched from the Pact broker"))
.arg(Arg::new("provider-names")
.long("provider-names")
.help("Consumer name to use to filter the Pacts fetched from the Pact broker (can be repeated)"))
.arg(Arg::new("provider-name")
.long("provider-name")
.alias("provider-names")
.requires("broker-url")
.action(ArgAction::Append)
.value_parser(clap::builder::NonEmptyStringValueParser::new())
.help("Provider names to use to filter the Pacts fetched from the Pact broker"))
.help("Provider name to use to filter the Pacts fetched from the Pact broker (can be repeated)"))
.arg(Arg::new("version")
.short('v')
.long("version")
Expand Down
8 changes: 4 additions & 4 deletions src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ Options:
Name of the header parameter containing the provider state to be used in case multiple matching interactions are found
--empty-provider-state
Include empty provider states when filtering with --provider-state
--consumer-names <consumer-names>
Consumer names to use to filter the Pacts fetched from the Pact broker
--provider-names <provider-names>
Provider names to use to filter the Pacts fetched from the Pact broker
--consumer-name <consumer-name>
Consumer name to use to filter the Pacts fetched from the Pact broker (can be repeated)
--provider-name <provider-name>
Provider name to use to filter the Pacts fetched from the Pact broker (can be repeated)
-v, --version
Print version information
-h, --help
Expand Down

0 comments on commit ab2c414

Please sign in to comment.