Skip to content

Commit 19fc435

Browse files
authored
Merge pull request #3 from hardfau1t/dev
feat(hook): pass args to hooks from cmdline args
2 parents 8444a39 + cf1caf2 commit 19fc435

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pigeon"
3-
version = "0.2.1"
3+
version = "0.2.2"
44
edition = "2021"
55

66
[dependencies]

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl Arguments {
3333
if self.list {
3434
services.view(&self.endpoint);
3535
} else {
36-
services.run(&self.endpoint)?;
36+
services.run(&self.endpoint, &self.args)?;
3737
}
3838
Ok(())
3939
}

src/registry/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl Bundle {
8686
);
8787
}
8888
}
89-
pub fn run<T: Borrow<str>>(&self, keys: &[T]) -> Result<(), anyhow::Error> {
89+
pub fn run<T: Borrow<str>>(&self, keys: &[T], flags: &[impl Borrow<str>]) -> Result<(), anyhow::Error> {
9090
let (Some((endpoint, environments)), _) = self.find(keys) else {
9191
error!("couldn't find endpoint with {}", keys.join("."));
9292
return Ok(());
@@ -114,7 +114,7 @@ impl Bundle {
114114
entry.or_insert(value.clone());
115115
});
116116
let built_endpoint = endpoint.substitute(&config_store)?;
117-
built_endpoint.execute(current_env.as_ref().try_into()?, &mut config_store)
117+
built_endpoint.execute(current_env.as_ref().try_into()?, &mut config_store, flags)
118118
}
119119

120120
fn build(package: &impl Borrow<str>, service_mods: HashMap<String, ServiceModule>) -> Self {
@@ -279,9 +279,10 @@ impl EndPoint<NotSubstituted> {
279279
}
280280

281281
impl EndPoint<Substituted> {
282-
fn execute(self, base_url: url::Url, config_store: &mut Store) -> anyhow::Result<()> {
283-
let request_hook_flags = Option::<&str>::None.as_slice();
284-
let response_hook_flags = Option::<&str>::None.as_slice();
282+
fn execute(self, base_url: url::Url, config_store: &mut Store, flags:&[impl Borrow<str>]) -> anyhow::Result<()> {
283+
let mut flags_iter = flags.split(|flag| &flag.borrow() == &"--");
284+
let request_hook_flags = flags_iter.next().unwrap_or(&[]);
285+
let response_hook_flags = flags_iter.next().unwrap_or(&[]);
285286
let Self {
286287
method,
287288
mut headers,

0 commit comments

Comments
 (0)