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

Upgrade clap #1383

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion uniffi_bindgen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ anyhow = "1"
askama = { version = "0.11", default-features = false, features = ["config"] }
bincode = "1.3"
camino = "1.0.8"
clap = { version = "3.1", features = ["cargo", "std", "derive"] }
clap = { version = "4.0", features = ["cargo", "std", "derive"] }
fs-err = "2.7.0"
goblin = "0.5"
heck = "0.4"
Expand Down
3 changes: 2 additions & 1 deletion uniffi_bindgen/src/bindings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use anyhow::{bail, Result};
use camino::Utf8Path;
use clap::ValueEnum;
use serde::{Deserialize, Serialize};

use crate::interface::ComponentInterface;
Expand All @@ -25,7 +26,7 @@ pub mod swift;
/// on the provided `TargetLanguage`. For convenience of calling code we also provide
/// a few `TryFrom` implementations to help guess the correct target language from
/// e.g. a file extension of command-line argument.
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, ValueEnum)]
pub enum TargetLanguage {
Kotlin,
Swift,
Expand Down
10 changes: 5 additions & 5 deletions uniffi_bindgen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ pub fn generate_component_scaffolding(
pub fn generate_bindings(
udl_file: &Utf8Path,
config_file_override: Option<&Utf8Path>,
target_languages: Vec<&str>,
target_languages: &[TargetLanguage],
out_dir_override: Option<&Utf8Path>,
library_file: Option<&Utf8Path>,
try_format_code: bool,
Expand All @@ -310,7 +310,7 @@ pub fn generate_bindings(
&config.bindings,
&component,
&out_dir,
language.try_into()?,
*language,
try_format_code,
)?;
}
Expand Down Expand Up @@ -522,8 +522,8 @@ enum Commands {
/// Generate foreign language bindings
Generate {
/// Foreign language(s) for which to build bindings.
#[clap(long, short, possible_values = &["kotlin", "python", "swift", "ruby"])]
language: Vec<String>,
#[clap(long, short, value_enum)]
language: Vec<TargetLanguage>,

/// Directory in which to write generated files. Default is same folder as .udl file.
#[clap(long, short)]
Expand Down Expand Up @@ -599,7 +599,7 @@ pub fn run_main() -> Result<()> {
} => generate_bindings(
udl_file,
config.as_deref(),
language.iter().map(String::as_str).collect(),
language,
out_dir.as_deref(),
lib_file.as_deref(),
!no_format,
Expand Down