Skip to content

Commit 24cf8d5

Browse files
committed
switch arg parsing to clap-derive
1 parent 7e1aabb commit 24cf8d5

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ repository = "https://github.com/John15321/rust-pip"
1212

1313
[dependencies]
1414
anyhow = { version = "1.0.58", features = ["backtrace"] }
15+
clap = { version = "3.2", features = ["derive"] }
1516
reqwest = { version = "0.11", features = ["blocking", "json"] }
16-
structopt = { version = "0.3.26", features = ["color"] }
17-
strum = "0.24.1"
18-
strum_macros = "0.24.2"
17+
strum = { version = "0.24.1", features = ["derive"] }
1918

2019

2120
[dev-dependencies]

src/main.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
use std::path::PathBuf;
2-
use structopt::StructOpt;
2+
use clap::{AppSettings, Parser};
33

4-
/// A basic example
5-
#[derive(StructOpt, Debug)]
6-
#[structopt(name = "rust-pip", about = "Python package manager written in Rust.")]
4+
/// Python package manager written in Rust
5+
#[derive(Parser, Debug)]
6+
#[clap(global_setting = AppSettings::DeriveDisplayOrder)]
77
enum Opt {
88
/// Install packages.
99
Install {},
1010
/// Download packages.
1111
Download {
12-
#[structopt(short = "n", long = "name")]
12+
#[clap(short = 'n', long = "name")]
1313
name: String,
14-
#[structopt(short = "i", long = "index", default_value = "https://pypi.org/")]
14+
#[clap(short = 'i', long = "index", default_value = "https://pypi.org/")]
1515
index: String,
1616
},
1717
/// Uninstall packages.
@@ -47,7 +47,7 @@ enum Opt {
4747
fn download_package(package_name: String, package_index: &String) {}
4848

4949
fn main() {
50-
let opt = Opt::from_args();
50+
let opt = Opt::parse();
5151
println!("{:#?}", opt);
5252

5353
match opt {

0 commit comments

Comments
 (0)