Skip to content

Commit b02bf55

Browse files
authored
enums: Update to clap 4.0 (#984)
1 parent af22fe8 commit b02bf55

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

enums/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = ["Calixte Denizet <cdenizet@mozilla.com>"]
55
edition = "2021"
66

77
[dependencies]
8-
clap = { version = "^3.2", features = ["derive"] }
8+
clap = { version = "^4.0", features = ["derive"] }
99
askama = "^0.11"
1010

1111
tree-sitter = "0.20.9"

enums/src/main.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
use std::path::PathBuf;
22

3+
use clap::builder::{PossibleValuesParser, TypedValueParser};
34
use clap::Parser;
45

56
use enums::*;
67

7-
#[derive(Debug)]
8+
#[derive(Debug, Clone)]
89
enum OutputLanguage {
910
Rust,
1011
Go,
@@ -44,7 +45,8 @@ struct Opts {
4445
#[clap(long, short, default_value = ".", value_parser)]
4546
output: PathBuf,
4647
/// Target language.
47-
#[clap(long, short, default_value = "rust", possible_values = OutputLanguage::variants())]
48+
#[clap(long, short, default_value = "rust", value_parser = PossibleValuesParser::new(OutputLanguage::variants())
49+
.map(|s| s.parse::<OutputLanguage>().unwrap()))]
4850
language: OutputLanguage,
4951
/// File name template.
5052
#[clap(long, short, default_value = "language_$")]

0 commit comments

Comments
 (0)