Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow API to reside at submodule of crate #642

Merged
merged 1 commit into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions progenitor-impl/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,20 @@ impl Generator {
})
.collect::<Vec<_>>();

let crate_ident = format_ident!("{}", crate_name);
let crate_path = syn::TypePath {
qself: None,
path: syn::parse_str(&crate_name).unwrap(),
};

let code = quote! {
use #crate_path::*;

pub struct Cli<T: CliOverride = ()> {
client: #crate_ident::Client,
client: Client,
over: T,
}
impl Cli {
pub fn new(client: #crate_ident::Client) -> Self {
pub fn new(client: Client) -> Self {
Self { client, over: () }
}

Expand All @@ -125,7 +130,7 @@ impl Generator {

impl<T: CliOverride> Cli<T> {
pub fn new_with_override(
client: #crate_ident::Client,
client: Client,
over: T,
) -> Self {
Self { client, over }
Expand Down
7 changes: 5 additions & 2 deletions progenitor-impl/src/httpmock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ impl Generator {
let then_impl =
methods.iter().map(|op| &op.then_impl).collect::<Vec<_>>();

let crate_ident = format_ident!("{}", crate_name);
let crate_path = syn::TypePath {
qself: None,
path: syn::parse_str(&crate_name).unwrap(),
};

let code = quote! {
pub mod operations {
Expand All @@ -89,7 +92,7 @@ impl Generator {
//! its inner type with a call to `into_inner()`. This can
//! be used to explicitly deviate from permitted values.

use #crate_ident::*;
use #crate_path::*;

#(
pub struct #when(httpmock::When);
Expand Down
7 changes: 4 additions & 3 deletions progenitor-impl/tests/output/buildomat-cli.out
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use sdk::*;
pub struct Cli<T: CliOverride = ()> {
client: sdk::Client,
client: Client,
over: T,
}

impl Cli {
pub fn new(client: sdk::Client) -> Self {
pub fn new(client: Client) -> Self {
Self { client, over: () }
}

Expand Down Expand Up @@ -317,7 +318,7 @@ impl Cli {
}

impl<T: CliOverride> Cli<T> {
pub fn new_with_override(client: sdk::Client, over: T) -> Self {
pub fn new_with_override(client: Client, over: T) -> Self {
Self { client, over }
}

Expand Down
7 changes: 4 additions & 3 deletions progenitor-impl/tests/output/keeper-cli.out
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use sdk::*;
pub struct Cli<T: CliOverride = ()> {
client: sdk::Client,
client: Client,
over: T,
}

impl Cli {
pub fn new(client: sdk::Client) -> Self {
pub fn new(client: Client) -> Self {
Self { client, over: () }
}

Expand Down Expand Up @@ -183,7 +184,7 @@ impl Cli {
}

impl<T: CliOverride> Cli<T> {
pub fn new_with_override(client: sdk::Client, over: T) -> Self {
pub fn new_with_override(client: Client, over: T) -> Self {
Self { client, over }
}

Expand Down
7 changes: 4 additions & 3 deletions progenitor-impl/tests/output/nexus-cli.out
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use sdk::*;
pub struct Cli<T: CliOverride = ()> {
client: sdk::Client,
client: Client,
over: T,
}

impl Cli {
pub fn new(client: sdk::Client) -> Self {
pub fn new(client: Client) -> Self {
Self { client, over: () }
}

Expand Down Expand Up @@ -5608,7 +5609,7 @@ impl Cli {
}

impl<T: CliOverride> Cli<T> {
pub fn new_with_override(client: sdk::Client, over: T) -> Self {
pub fn new_with_override(client: Client, over: T) -> Self {
Self { client, over }
}

Expand Down
7 changes: 4 additions & 3 deletions progenitor-impl/tests/output/param-collision-cli.out
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use sdk::*;
pub struct Cli<T: CliOverride = ()> {
client: sdk::Client,
client: Client,
over: T,
}

impl Cli {
pub fn new(client: sdk::Client) -> Self {
pub fn new(client: Client) -> Self {
Self { client, over: () }
}

Expand Down Expand Up @@ -63,7 +64,7 @@ impl Cli {
}

impl<T: CliOverride> Cli<T> {
pub fn new_with_override(client: sdk::Client, over: T) -> Self {
pub fn new_with_override(client: Client, over: T) -> Self {
Self { client, over }
}

Expand Down
7 changes: 4 additions & 3 deletions progenitor-impl/tests/output/param-overrides-cli.out
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use sdk::*;
pub struct Cli<T: CliOverride = ()> {
client: sdk::Client,
client: Client,
over: T,
}

impl Cli {
pub fn new(client: sdk::Client) -> Self {
pub fn new(client: Client) -> Self {
Self { client, over: () }
}

Expand Down Expand Up @@ -35,7 +36,7 @@ impl Cli {
}

impl<T: CliOverride> Cli<T> {
pub fn new_with_override(client: sdk::Client, over: T) -> Self {
pub fn new_with_override(client: Client, over: T) -> Self {
Self { client, over }
}

Expand Down
7 changes: 4 additions & 3 deletions progenitor-impl/tests/output/propolis-server-cli.out
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use sdk::*;
pub struct Cli<T: CliOverride = ()> {
client: sdk::Client,
client: Client,
over: T,
}

impl Cli {
pub fn new(client: sdk::Client) -> Self {
pub fn new(client: Client) -> Self {
Self { client, over: () }
}

Expand Down Expand Up @@ -139,7 +140,7 @@ impl Cli {
}

impl<T: CliOverride> Cli<T> {
pub fn new_with_override(client: sdk::Client, over: T) -> Self {
pub fn new_with_override(client: Client, over: T) -> Self {
Self { client, over }
}

Expand Down
Loading