Skip to content

Commit 8f1b832

Browse files
andjo403michaelwoerister
authored andcommitted
Change Cli parser from StructOpt to Clap
1 parent 6b8bc6d commit 8f1b832

File tree

12 files changed

+35
-35
lines changed

12 files changed

+35
-35
lines changed

crox/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ analyzeme = { path = "../analyzeme" }
1010
rustc-hash = "1.0.1"
1111
serde = { version = "1.0", features = [ "derive" ] }
1212
serde_json = "1.0"
13-
structopt = "0.3"
13+
clap = { version = "3.2", features = ["derive"] }

crox/src/main.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH};
77
use analyzeme::{ProfilingData, Timestamp};
88
use measureme::file_header::FILE_EXTENSION;
99

10+
use clap::Parser;
1011
use serde::ser::SerializeSeq;
1112
use serde::{Serialize, Serializer};
1213
use serde_json::json;
1314
use std::cmp;
14-
use structopt::StructOpt;
1515

1616
fn as_micros<S: Serializer>(d: &Duration, s: S) -> Result<S::Ok, S::Error> {
1717
let v = (d.as_secs() * 1_000_000) + (d.subsec_nanos() as u64 / 1_000);
@@ -43,18 +43,18 @@ struct Event {
4343
args: Option<FxHashMap<String, String>>,
4444
}
4545

46-
#[derive(StructOpt, Debug)]
46+
#[derive(Parser, Debug)]
4747
struct Opt {
48-
#[structopt(required_unless = "dir")]
48+
#[clap(required_unless = "dir")]
4949
file_prefix: Vec<PathBuf>,
5050
/// all event trace files in dir will be merged to one chrome_profiler.json file
51-
#[structopt(long = "dir")]
51+
#[clap(long = "dir")]
5252
dir: Option<PathBuf>,
5353
/// collapse threads without overlapping events
54-
#[structopt(long = "collapse-threads")]
54+
#[clap(long = "collapse-threads")]
5555
collapse_threads: bool,
5656
/// filter out events with shorter duration (in microseconds)
57-
#[structopt(long = "minimum-duration")]
57+
#[clap(long = "minimum-duration")]
5858
minimum_duration: Option<u128>,
5959
}
6060

flamegraph/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ license = "MIT OR Apache-2.0"
88
[dependencies]
99
measureme = { path = "../measureme" }
1010
analyzeme = { path = "../analyzeme" }
11-
structopt = "0.3"
11+
clap = { version = "3.2", features = ["derive"] }
1212
inferno = { version="0.9.1", default-features = false }

flamegraph/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use std::io::BufWriter;
44
use std::path::PathBuf;
55

66
use analyzeme::{collapse_stacks, ProfilingData};
7+
use clap::Parser;
78
use inferno::flamegraph::{from_lines, Options as FlamegraphOptions};
8-
use structopt::StructOpt;
99

10-
#[derive(StructOpt, Debug)]
10+
#[derive(Parser, Debug)]
1111
struct Opt {
1212
file_prefix: PathBuf,
1313
}

mmedit/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ edition = "2018"
66
[dependencies]
77
measureme = { path = "../measureme" }
88
decodeme = { path = "../decodeme" }
9-
structopt = "0.3"
9+
clap = { version = "3.2", features = ["derive"] }

mmedit/src/main.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ use std::{convert::TryInto, error::Error, path::PathBuf};
22

33
use decodeme::{read_file_header, PageTag, FILE_HEADER_SIZE, FILE_MAGIC_TOP_LEVEL};
44

5-
use structopt::StructOpt;
5+
use clap::Parser;
66

7-
#[derive(StructOpt, Debug)]
7+
#[derive(Parser, Debug)]
88
struct TruncateOpt {
99
file: PathBuf,
1010
}
1111

12-
#[derive(StructOpt, Debug)]
12+
#[derive(Parser, Debug)]
1313
enum Opt {
1414
/// Truncate to a single page per tag
15-
#[structopt(name = "truncate")]
15+
#[clap(name = "truncate")]
1616
Truncate(TruncateOpt),
1717
}
1818

mmview/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ license = "MIT OR Apache-2.0"
88
[dependencies]
99
analyzeme = { path = "../analyzeme" }
1010
measureme = { path = "../measureme" }
11-
structopt = "0.3"
11+
clap = { version = "3.2", features = ["derive"] }

mmview/src/main.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
use analyzeme::{Event, EventPayload, ProfilingData, Timestamp};
2+
use clap::Parser;
23
use std::error::Error;
34
use std::path::PathBuf;
45
use std::time::{Duration, SystemTime};
5-
use structopt::StructOpt;
66

7-
#[derive(StructOpt, Debug)]
7+
#[derive(Parser, Debug)]
88
struct Opt {
99
file_prefix: PathBuf,
1010

1111
/// Filter to events which occured on the specified thread id
12-
#[structopt(short = "t", long = "thread-id")]
12+
#[clap(short = 't', long = "thread-id")]
1313
thread_id: Option<u32>,
1414
}
1515

stack_collapse/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ license = "MIT OR Apache-2.0"
88
[dependencies]
99
measureme = { path = "../measureme" }
1010
analyzeme = { path = "../analyzeme" }
11-
structopt = "0.3"
11+
clap = { version = "3.2", features = ["derive"] }

stack_collapse/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ use std::io::{BufWriter, Write};
44
use std::path::PathBuf;
55

66
use analyzeme::{collapse_stacks, ProfilingData};
7-
use structopt::StructOpt;
7+
use clap::Parser;
88

9-
#[derive(StructOpt, Debug)]
9+
#[derive(Parser, Debug)]
1010
struct Opt {
1111
file_prefix: PathBuf,
1212
}

summarize/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ prettytable-rs = "0.10"
1212
rustc-hash = "1.0.1"
1313
serde = { version = "1.0", features = [ "derive" ] }
1414
serde_json = "1.0"
15-
structopt = "0.3"
15+
clap = { version = "3.2", features = ["derive"] }

summarize/src/main.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -8,54 +8,54 @@ use std::fs::File;
88
use std::io::{BufReader, BufWriter};
99
use std::{path::PathBuf, time::Duration};
1010

11+
use clap::Parser;
1112
use prettytable::{Cell, Row, Table};
1213
use serde::Serialize;
13-
use structopt::StructOpt;
1414

1515
mod aggregate;
1616
mod diff;
1717

18-
#[derive(StructOpt, Debug)]
18+
#[derive(Parser, Debug)]
1919
struct AggregateOpt {
2020
files: Vec<PathBuf>,
2121
}
2222

23-
#[derive(StructOpt, Debug)]
23+
#[derive(Parser, Debug)]
2424
struct DiffOpt {
2525
base: PathBuf,
2626
change: PathBuf,
2727

28-
#[structopt(short = "e", long = "exclude")]
28+
#[clap(short = 'e', long = "exclude")]
2929
exclude: Vec<String>,
3030

31-
#[structopt(long = "json")]
31+
#[clap(long = "json")]
3232
json: bool,
3333
}
3434

35-
#[derive(StructOpt, Debug)]
35+
#[derive(Parser, Debug)]
3636
struct SummarizeOpt {
3737
file_prefix: PathBuf,
3838

3939
/// Writes the analysis to a json file next to <file_prefix> instead of stdout
40-
#[structopt(long = "json")]
40+
#[clap(long = "json")]
4141
json: bool,
4242

4343
/// Filter the output to items whose self-time is greater than this value
44-
#[structopt(short = "pa", long = "percent-above", default_value = "0.0")]
44+
#[clap(short = 'p', long = "percent-above", default_value = "0.0")]
4545
percent_above: f64,
4646
}
4747

48-
#[derive(StructOpt, Debug)]
48+
#[derive(Parser, Debug)]
4949
enum Opt {
5050
/// Processes a set of trace files with identical events and analyze variance
51-
#[structopt(name = "aggregate")]
51+
#[clap(name = "aggregate")]
5252
Aggregate(AggregateOpt),
5353

54-
#[structopt(name = "diff")]
54+
#[clap(name = "diff")]
5555
Diff(DiffOpt),
5656

5757
/// Processes trace files and produces a summary
58-
#[structopt(name = "summarize")]
58+
#[clap(name = "summarize")]
5959
Summarize(SummarizeOpt),
6060
}
6161

0 commit comments

Comments
 (0)