mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-30 04:44:44 +00:00
Add argparse module
This commit is contained in:
parent
22857229ee
commit
6fc382d46c
2 changed files with 18 additions and 2 deletions
|
@ -6,7 +6,8 @@ use std::process::Command;
|
||||||
use crate::serialize::get_magic_num_from_bytes;
|
use crate::serialize::get_magic_num_from_bytes;
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
pub const BUILTIN_PYTHON_MODS: [&str; 23] = [
|
pub const BUILTIN_PYTHON_MODS: [&str; 24] = [
|
||||||
|
"argparse",
|
||||||
"copy",
|
"copy",
|
||||||
"datetime",
|
"datetime",
|
||||||
"glob",
|
"glob",
|
||||||
|
@ -32,7 +33,8 @@ pub const BUILTIN_PYTHON_MODS: [&str; 23] = [
|
||||||
"zipfile",
|
"zipfile",
|
||||||
];
|
];
|
||||||
#[cfg(not(unix))]
|
#[cfg(not(unix))]
|
||||||
pub const BUILTIN_PYTHON_MODS: [&str; 22] = [
|
pub const BUILTIN_PYTHON_MODS: [&str; 23] = [
|
||||||
|
"argparse",
|
||||||
"copy",
|
"copy",
|
||||||
"datetime",
|
"datetime",
|
||||||
"glob",
|
"glob",
|
||||||
|
|
14
compiler/erg_compiler/lib/pystd/argparse.d.er
Normal file
14
compiler/erg_compiler/lib/pystd/argparse.d.er
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
._StoreAction: ClassType
|
||||||
|
|
||||||
|
.ArgumentParser!: ClassType
|
||||||
|
.new = 'ArgumentParser': (description := Str, prog := Str) -> .ArgumentParser!
|
||||||
|
.ArgumentParser!.add_argument!: (
|
||||||
|
name: Str, # TODO: var-args
|
||||||
|
action := Str or NoneType,
|
||||||
|
default := Obj or NoneType,
|
||||||
|
type := Type,
|
||||||
|
required := Bool,
|
||||||
|
help := Str or NoneType,
|
||||||
|
choices := Obj or NoneType,
|
||||||
|
) => ._StoreAction
|
||||||
|
.ArgumentParser!.parse_args!: (args := Str or [Str; _] or NoneType,) => Obj # TODO: type with dependent types
|
Loading…
Add table
Add a link
Reference in a new issue