Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8961efc

Browse filesBrowse files
committed
Upgrade clap to v3
1 parent 71d6c0e commit 8961efc
Copy full SHA for 8961efc

File tree

3 files changed

+82
-79
lines changed
Filter options

3 files changed

+82
-79
lines changed

‎Cargo.lock

Copy file name to clipboardExpand all lines: Cargo.lock
+30-25Lines changed: 30 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml

Copy file name to clipboardExpand all lines: Cargo.toml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ssl-vendor = ["rustpython-stdlib/ssl-vendor"]
3333
[dependencies]
3434
log = "0.4"
3535
env_logger = { version = "0.9.0", default-features = false, features = ["atty", "termcolor"] }
36-
clap = "2.33"
36+
clap = "3"
3737
rustpython-compiler = { path = "compiler/porcelain", version = "0.1.1" }
3838
rustpython-parser = { path = "parser", version = "0.1.1" }
3939
rustpython-vm = { path = "vm", version = "0.1.1", default-features = false, features = ["compile-parse"] }

‎src/lib.rs

Copy file name to clipboardExpand all lines: src/lib.rs
+51-53Lines changed: 51 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
//! it will have your modules loaded into the vm.
3838
#![allow(clippy::needless_doctest_main, clippy::unnecessary_wraps)]
3939

40-
#[macro_use]
4140
extern crate clap;
4241
extern crate env_logger;
4342
#[macro_use]
@@ -68,8 +67,7 @@ where
6867
#[cfg(feature = "flame-it")]
6968
let main_guard = flame::start_guard("RustPython main");
7069
env_logger::init();
71-
let app = App::new("RustPython");
72-
let matches = parse_arguments(app);
70+
let matches = parse_arguments();
7371
let settings = create_settings(&matches);
7472

7573
// don't translate newlines (\r\n <=> \n)
@@ -160,125 +158,125 @@ fn flush_std(vm: &VirtualMachine) {
160158
}
161159
}
162160

163-
fn parse_arguments<'a>(app: App<'a, '_>) -> ArgMatches<'a> {
164-
let app = app
161+
fn parse_arguments() -> ArgMatches {
162+
let app = App::new("RustPython")
165163
.setting(AppSettings::TrailingVarArg)
166-
.version(crate_version!())
167-
.author(crate_authors!())
164+
.version(env!("CARGO_PKG_VERSION"))
165+
.author(env!("CARGO_PKG_AUTHORS"))
168166
.about("Rust implementation of the Python language")
169-
.usage("rustpython [OPTIONS] [-c CMD | -m MODULE | FILE] [PYARGS]...")
167+
.override_usage("rustpython [OPTIONS] [-c CMD | -m MODULE | FILE] [PYARGS]...")
170168
.arg(
171-
Arg::with_name("script")
169+
Arg::new("script")
172170
.required(false)
173171
.allow_hyphen_values(true)
174-
.multiple(true)
172+
.multiple_values(true)
175173
.value_name("script, args")
176174
.min_values(1),
177175
)
178176
.arg(
179-
Arg::with_name("c")
180-
.short("c")
177+
Arg::new("c")
178+
.short('c')
181179
.takes_value(true)
182180
.allow_hyphen_values(true)
183-
.multiple(true)
181+
.multiple_values(true)
184182
.value_name("cmd, args")
185183
.min_values(1)
186184
.help("run the given string as a program"),
187185
)
188186
.arg(
189-
Arg::with_name("m")
190-
.short("m")
187+
Arg::new("m")
188+
.short('m')
191189
.takes_value(true)
192190
.allow_hyphen_values(true)
193-
.multiple(true)
191+
.multiple_values(true)
194192
.value_name("module, args")
195193
.min_values(1)
196194
.help("run library module as script"),
197195
)
198196
.arg(
199-
Arg::with_name("install_pip")
197+
Arg::new("install_pip")
200198
.long("install-pip")
201199
.takes_value(true)
202200
.allow_hyphen_values(true)
203-
.multiple(true)
201+
.multiple_values(true)
204202
.value_name("get-pip args")
205203
.min_values(0)
206204
.help("install the pip package manager for rustpython; \
207205
requires rustpython be build with the ssl feature enabled."
208206
),
209207
)
210208
.arg(
211-
Arg::with_name("optimize")
212-
.short("O")
213-
.multiple(true)
209+
Arg::new("optimize")
210+
.short('O')
211+
.multiple_occurrences(true)
214212
.help("Optimize. Set __debug__ to false. Remove debug statements."),
215213
)
216214
.arg(
217-
Arg::with_name("verbose")
218-
.short("v")
219-
.multiple(true)
215+
Arg::new("verbose")
216+
.short('v')
217+
.multiple_occurrences(true)
220218
.help("Give the verbosity (can be applied multiple times)"),
221219
)
222-
.arg(Arg::with_name("debug").short("d").help("Debug the parser."))
220+
.arg(Arg::new("debug").short('d').help("Debug the parser."))
223221
.arg(
224-
Arg::with_name("quiet")
225-
.short("q")
222+
Arg::new("quiet")
223+
.short('q')
226224
.help("Be quiet at startup."),
227225
)
228226
.arg(
229-
Arg::with_name("inspect")
230-
.short("i")
227+
Arg::new("inspect")
228+
.short('i')
231229
.help("Inspect interactively after running the script."),
232230
)
233231
.arg(
234-
Arg::with_name("no-user-site")
235-
.short("s")
232+
Arg::new("no-user-site")
233+
.short('s')
236234
.help("don't add user site directory to sys.path."),
237235
)
238236
.arg(
239-
Arg::with_name("no-site")
240-
.short("S")
237+
Arg::new("no-site")
238+
.short('S')
241239
.help("don't imply 'import site' on initialization"),
242240
)
243241
.arg(
244-
Arg::with_name("dont-write-bytecode")
245-
.short("B")
242+
Arg::new("dont-write-bytecode")
243+
.short('B')
246244
.help("don't write .pyc files on import"),
247245
)
248246
.arg(
249-
Arg::with_name("ignore-environment")
250-
.short("E")
247+
Arg::new("ignore-environment")
248+
.short('E')
251249
.help("Ignore environment variables PYTHON* such as PYTHONPATH"),
252250
)
253251
.arg(
254-
Arg::with_name("isolate")
255-
.short("I")
252+
Arg::new("isolate")
253+
.short('I')
256254
.help("isolate Python from the user's environment (implies -E and -s)"),
257255
)
258256
.arg(
259-
Arg::with_name("implementation-option")
260-
.short("X")
257+
Arg::new("implementation-option")
258+
.short('X')
261259
.takes_value(true)
262-
.multiple(true)
260+
.multiple_occurrences(true)
263261
.number_of_values(1)
264262
.help("set implementation-specific option"),
265263
)
266264
.arg(
267-
Arg::with_name("warning-control")
268-
.short("W")
265+
Arg::new("warning-control")
266+
.short('W')
269267
.takes_value(true)
270-
.multiple(true)
268+
.multiple_occurrences(true)
271269
.number_of_values(1)
272270
.help("warning control; arg is action:message:category:module:lineno"),
273271
)
274272
.arg(
275-
Arg::with_name("bytes-warning")
276-
.short("b")
277-
.multiple(true)
273+
Arg::new("bytes-warning")
274+
.short('b')
275+
.multiple_occurrences(true)
278276
.help("issue warnings about using bytes where strings are usually expected (-bb: issue errors)"),
279277
).arg(
280-
Arg::with_name("unbuffered")
281-
.short("u")
278+
Arg::new("unbuffered")
279+
.short('u')
282280
.help(
283281
"force the stdout and stderr streams to be unbuffered; \
284282
this option has no effect on stdin; also PYTHONUNBUFFERED=x",
@@ -287,13 +285,13 @@ fn parse_arguments<'a>(app: App<'a, '_>) -> ArgMatches<'a> {
287285
#[cfg(feature = "flame-it")]
288286
let app = app
289287
.arg(
290-
Arg::with_name("profile_output")
288+
Arg::new("profile_output")
291289
.long("profile-output")
292290
.takes_value(true)
293291
.help("the file to output the profiling information to"),
294292
)
295293
.arg(
296-
Arg::with_name("profile_format")
294+
Arg::new("profile_format")
297295
.long("profile-format")
298296
.takes_value(true)
299297
.help("the profile format to output the profiling information in"),
@@ -609,7 +607,7 @@ fn run_rustpython(vm: &VirtualMachine, matches: &ArgMatches) -> PyResult<()> {
609607
} else {
610608
println!(
611609
"Welcome to the magnificent Rust Python {} interpreter \u{1f631} \u{1f596}",
612-
crate_version!()
610+
env!("CARGO_PKG_VERSION")
613611
);
614612
shell::run_shell(vm, scope)?;
615613
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.