Skip to content

Commit 3aed532

Browse files
Refactor: Clap attribute macros from #[clap(...)] to #[arg(...)] and #[command(...)] in v4.x (#2003)
* Update main.rs * Update main.rs * Update CHANGELOG.md to refactor: Clap attribute macros from #[clap(...)] to #[arg(...)] and #[command(...)] in v4.x --------- Co-authored-by: Julián González Calderón <[email protected]>
1 parent 5307101 commit 3aed532

File tree

4 files changed

+37
-34
lines changed

4 files changed

+37
-34
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#### Upcoming Changes
44

5+
* refactor: Clap attribute macros from #[clap(...)] to #[arg(...)] and #[command(...)] in v4.x [#2003] (https://github.com/lambdaclass/cairo-vm/pull/2003)
6+
57
* fix: Fix `WriteReturnFp` error due to a bad loading of initial gas [#2015](https://github.com/lambdaclass/cairo-vm/pull/2015)
68

79
* refactor: Replaces security anyhow errors with enum variants [#1946](https://github.com/lambdaclass/cairo-vm/pull/1946)

cairo-vm-cli/src/main.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,51 +32,51 @@ use mimalloc::MiMalloc;
3232
static ALLOC: MiMalloc = MiMalloc;
3333

3434
#[derive(Parser, Debug)]
35-
#[clap(author, version, about, long_about = None)]
35+
#[command(author, version, about, long_about = None)]
3636
struct Args {
37-
#[clap(value_parser, value_hint=ValueHint::FilePath)]
37+
#[arg(value_parser, value_hint=ValueHint::FilePath)]
3838
filename: PathBuf,
39-
#[clap(long = "trace_file", value_parser)]
39+
#[arg(long = "trace_file", value_parser)]
4040
trace_file: Option<PathBuf>,
41-
#[structopt(long = "print_output")]
41+
#[arg(long = "print_output")]
4242
print_output: bool,
43-
#[structopt(long = "entrypoint", default_value = "main")]
43+
#[arg(long = "entrypoint", default_value = "main")]
4444
entrypoint: String,
45-
#[structopt(long = "memory_file")]
45+
#[arg(long = "memory_file")]
4646
memory_file: Option<PathBuf>,
47-
/// When using dynamic layout, it's parameters must be specified through a layout params file.
48-
#[clap(long = "layout", default_value = "plain", value_enum)]
47+
/// When using dynamic layout, its parameters must be specified through a layout params file.
48+
#[arg(long = "layout", default_value = "plain", value_enum)]
4949
layout: LayoutName,
5050
/// Required when using with dynamic layout.
5151
/// Ignored otherwise.
52-
#[clap(long = "cairo_layout_params_file", required_if_eq("layout", "dynamic"))]
52+
#[arg(long = "cairo_layout_params_file", required_if_eq("layout", "dynamic"))]
5353
cairo_layout_params_file: Option<PathBuf>,
54-
#[structopt(long = "proof_mode")]
54+
#[arg(long = "proof_mode")]
5555
proof_mode: bool,
56-
#[structopt(long = "secure_run")]
56+
#[arg(long = "secure_run")]
5757
secure_run: Option<bool>,
58-
#[clap(long = "air_public_input", requires = "proof_mode")]
58+
#[arg(long = "air_public_input", requires = "proof_mode")]
5959
air_public_input: Option<String>,
60-
#[clap(
60+
#[arg(
6161
long = "air_private_input",
6262
requires_all = ["proof_mode", "trace_file", "memory_file"]
6363
)]
6464
air_private_input: Option<String>,
65-
#[clap(
65+
#[arg(
6666
long = "cairo_pie_output",
6767
// We need to add these air_private_input & air_public_input or else
6868
// passing cairo_pie_output + either of these without proof_mode will not fail
6969
conflicts_with_all = ["proof_mode", "air_private_input", "air_public_input"]
7070
)]
7171
cairo_pie_output: Option<String>,
72-
#[structopt(long = "merge_extra_segments")]
72+
#[arg(long = "merge_extra_segments")]
7373
merge_extra_segments: bool,
74-
#[structopt(long = "allow_missing_builtins")]
74+
#[arg(long = "allow_missing_builtins")]
7575
allow_missing_builtins: Option<bool>,
76-
#[structopt(long = "tracer")]
76+
#[arg(long = "tracer")]
7777
#[cfg(feature = "with_tracer")]
7878
tracer: bool,
79-
#[structopt(
79+
#[arg(
8080
long = "run_from_cairo_pie",
8181
// We need to add these air_private_input & air_public_input or else
8282
// passing run_from_cairo_pie + either of these without proof_mode will not fail

cairo1-run/src/main.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,49 +17,49 @@ use std::{
1717
};
1818

1919
#[derive(Parser, Debug)]
20-
#[clap(author, version, about, long_about = None)]
20+
#[command(author, version, about, long_about = None)]
2121
struct Args {
22-
#[clap(value_parser, value_hint=ValueHint::FilePath)]
22+
#[arg(value_parser, value_hint=ValueHint::FilePath)]
2323
filename: PathBuf,
24-
#[clap(long = "trace_file", value_parser)]
24+
#[arg(long = "trace_file", value_parser)]
2525
trace_file: Option<PathBuf>,
26-
#[structopt(long = "memory_file")]
26+
#[arg(long = "memory_file")]
2727
memory_file: Option<PathBuf>,
28-
/// When using dynamic layout, it's parameters must be specified through a layout params file.
29-
#[clap(long = "layout", default_value = "plain", value_enum)]
28+
/// When using dynamic layout, its parameters must be specified through a layout params file.
29+
#[arg(long = "layout", default_value = "plain", value_enum)]
3030
layout: LayoutName,
3131
/// Required when using with dynamic layout.
3232
/// Ignored otherwise.
33-
#[clap(long = "cairo_layout_params_file", required_if_eq("layout", "dynamic"))]
33+
#[arg(long = "cairo_layout_params_file", required_if_eq("layout", "dynamic"))]
3434
cairo_layout_params_file: Option<PathBuf>,
35-
#[clap(long = "proof_mode", value_parser)]
35+
#[arg(long = "proof_mode", value_parser)]
3636
proof_mode: bool,
37-
#[clap(long = "air_public_input", requires = "proof_mode")]
37+
#[arg(long = "air_public_input", requires = "proof_mode")]
3838
air_public_input: Option<PathBuf>,
39-
#[clap(
39+
#[arg(
4040
long = "air_private_input",
4141
requires_all = ["proof_mode", "trace_file", "memory_file"]
4242
)]
4343
air_private_input: Option<PathBuf>,
44-
#[clap(
44+
#[arg(
4545
long = "cairo_pie_output",
4646
// We need to add these air_private_input & air_public_input or else
4747
// passing cairo_pie_output + either of these without proof_mode will not fail
4848
conflicts_with_all = ["proof_mode", "air_private_input", "air_public_input"]
4949
)]
5050
cairo_pie_output: Option<PathBuf>,
51-
#[clap(long = "merge_extra_segments", value_parser)]
51+
#[arg(long = "merge_extra_segments", value_parser)]
5252
merge_extra_segments: bool,
5353
// Arguments should be spaced, with array elements placed between brackets
5454
// For example " --args '1 2 [1 2 3]'" will yield 3 arguments, with the last one being an array of 3 elements
55-
#[clap(long = "args", default_value = "", value_parser=process_args, conflicts_with = "args_file")]
55+
#[arg(long = "args", default_value = "", value_parser=process_args, conflicts_with = "args_file")]
5656
args: FuncArgs,
5757
// Same rules from `args` apply here
58-
#[clap(long = "args_file", value_parser, value_hint=ValueHint::FilePath, conflicts_with = "args")]
58+
#[arg(long = "args_file", value_parser, value_hint=ValueHint::FilePath, conflicts_with = "args")]
5959
args_file: Option<PathBuf>,
60-
#[clap(long = "print_output", value_parser)]
60+
#[arg(long = "print_output", value_parser)]
6161
print_output: bool,
62-
#[clap(
62+
#[arg(
6363
long = "append_return_values",
6464
// We need to add these air_private_input & air_public_input or else
6565
// passing cairo_pie_output + either of these without proof_mode will not fail

corelib

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cairo1-run/corelib/

0 commit comments

Comments
 (0)