Skip to content

Commit b4213f0

Browse files
committed
add arg to cargo-progenitor
1 parent 090b80b commit b4213f0

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

cargo-progenitor/src/main.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::{
99
use anyhow::{bail, Result};
1010
use clap::{Parser, ValueEnum};
1111
use openapiv3::OpenAPI;
12-
use progenitor::{GenerationSettings, Generator, InterfaceStyle, TagStyle};
12+
use progenitor::{GenerationSettings, Generator, InterfaceStyle, OperationIdStrategy, TagStyle};
1313
use progenitor_impl::space_out_items;
1414

1515
fn is_non_release() -> bool {
@@ -54,6 +54,9 @@ struct Args {
5454
/// Include client code rather than depending on progenitor-client
5555
#[clap(default_value = match is_non_release() { true => "true", false => "false" }, long, action = clap::ArgAction::Set)]
5656
include_client: bool,
57+
58+
#[clap(value_enum, long, default_value_t = OperationIdStrategyArg::RejectMissing)]
59+
operation_id_strategy: OperationIdStrategyArg,
5760
}
5861

5962
#[derive(Copy, Clone, ValueEnum)]
@@ -86,6 +89,23 @@ impl From<TagArg> for TagStyle {
8689
}
8790
}
8891

92+
#[derive(Copy, Clone, ValueEnum)]
93+
enum OperationIdStrategyArg {
94+
RejectMissing,
95+
OmitMissing,
96+
GenerateMissing,
97+
}
98+
99+
impl From<OperationIdStrategyArg> for OperationIdStrategy {
100+
fn from(arg: OperationIdStrategyArg) -> Self {
101+
match arg {
102+
OperationIdStrategyArg::RejectMissing => OperationIdStrategy::RejectMissing,
103+
OperationIdStrategyArg::OmitMissing => OperationIdStrategy::OmitMissing,
104+
OperationIdStrategyArg::GenerateMissing => OperationIdStrategy::GenerateMissing,
105+
}
106+
}
107+
}
108+
89109
fn reformat_code(input: String) -> String {
90110
let config = rustfmt_wrapper::config::Config {
91111
normalize_doc_attributes: Some(true),

0 commit comments

Comments
 (0)