Skip to content

Commit

Permalink
support --version flag again
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtbuilds committed Dec 14, 2023
1 parent a4f5d5a commit d10c5a4
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
5 changes: 2 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion core/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,6 @@ pub struct OutputConfig {
pub config: ConfigFlags,

pub github_repo: Option<String>,
}

pub version: Option<String>,
}
4 changes: 4 additions & 0 deletions libninja/src/command/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ pub struct Generate {
#[clap(short, long)]
output_dir: Option<String>,

#[clap(short, long)]
version: Option<String>,

/// config options
#[clap(short, long)]
config: Vec<Config>,
Expand Down Expand Up @@ -70,6 +73,7 @@ impl Generate {
package_name,
service_name: self.name.to_case(Case::Pascal),
github_repo: self.repo,
version: self.version,
})
}
}
1 change: 1 addition & 0 deletions libninja/src/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ pub fn generate_rust_library(spec: OpenAPI, opts: OutputConfig) -> Result<()> {
if let Some(github_repo) = &opts.github_repo {
context.insert("github_repo".to_string(), github_repo.to_string());
} else {
println!("Because this is a first-time generation, please provide additional information.");
print!("Please provide a Github repo name (e.g. libninja/plaid-rs): ");
let github_repo: String = read!("{}\n");
context.insert("github_repo".to_string(), github_repo);
Expand Down
4 changes: 3 additions & 1 deletion libninja/src/rust/cargo_toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ pub fn update_cargo_toml(extras: &Extras, opts: &OutputConfig, context: &HashMap
});
let package = m.package.as_mut().expect("Cargo.toml must have a package section");

if let Inheritable::Set(t) = &mut package.version {
if let Some(v) = &opts.version {
package.version = Inheritable::Set(v.clone());
} else if let Inheritable::Set(t) = &mut package.version {
if t == "" {
*t = "0.1.0".to_string();
} else {
Expand Down
1 change: 1 addition & 0 deletions libninja/tests/basic/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ pub fn test_build_full_library_recurly() -> Result<()> {
language: Language::Rust,
config: Default::default(),
github_repo: Some("libninjacom/recurly".to_string()),
version: None,
};
generate_library(spec, opts)
}

0 comments on commit d10c5a4

Please sign in to comment.