From d5de65fdb1802cdf498d65d93397f290813c377c Mon Sep 17 00:00:00 2001 From: muqiuhan Date: Tue, 9 Sep 2025 06:17:00 +0000 Subject: deploy: 9665097f0fa0dae9f92123fac54d26c0818758a5 --- .../index.html" | 9 ++- 2024/06/27/OCaml-News-2024-5/index.html | 94 ++++++++++++---------- .../index.html" | 6 +- 3 files changed, 64 insertions(+), 45 deletions(-) (limited to '2024/06') diff --git "a/2024/06/06/NET-AOT-\344\270\213\347\232\204-F-\345\221\275\344\273\244\350\241\214\345\217\202\346\225\260\350\247\243\346\236\220\345\272\223\351\200\211\346\213\251/index.html" "b/2024/06/06/NET-AOT-\344\270\213\347\232\204-F-\345\221\275\344\273\244\350\241\214\345\217\202\346\225\260\350\247\243\346\236\220\345\272\223\351\200\211\346\213\251/index.html" index 68a607bf..1c605526 100644 --- "a/2024/06/06/NET-AOT-\344\270\213\347\232\204-F-\345\221\275\344\273\244\350\241\214\345\217\202\346\225\260\350\247\243\346\236\220\345\272\223\351\200\211\346\213\251/index.html" +++ "b/2024/06/06/NET-AOT-\344\270\213\347\232\204-F-\345\221\275\344\273\244\350\241\214\345\217\202\346\225\260\350\247\243\346\236\220\345\272\223\351\200\211\346\213\251/index.html" @@ -192,9 +192,12 @@
-

Argu 不支持 AOT,不过用 F# 的话可以看整个 .NET 的生态,我看了一下 C# 的 CommandLineParser:
https://github.com/commandlineparser

-

在这个 PR 中支持了 Native AOT
https://github.com/commandlineparser/commandline/pull/913

-

除此之外,还有一个更加精巧的 F# 库可以用,只有两百多行:
https://github.com/B2R2-org/FsOptParse/

+

Argu 不支持 AOT,不过用 F# 的话可以看整个 .NET 的生态,我看了一下 C# 的 CommandLineParser:
+https://github.com/commandlineparser

+

在这个 PR 中支持了 Native AOT
+https://github.com/commandlineparser/commandline/pull/913

+

除此之外,还有一个更加精巧的 F# 库可以用,只有两百多行:
+https://github.com/B2R2-org/FsOptParse/

AOT 后的大小很可观,并且支持 full trim.

用例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
(** defines a state to pass to the option parser *)
type opts =
{
optX : int;
optY : bool;
optZ : string;
}

(** default option state *)
let defaultOpts =
{
optX = 0;
optY = false;
optZ = "";
}

(*
An example command line specification, which is a list of Options.
Each Option describes a command line option (switch) that is specified with
either a short (a single-dash option) or long option (a double-dash option).
*)
let spec =
[
(* This option can be specified with -x <NUM>. There is an extra argument to
specify a value in integer. *)
Option ((* description of the option *)
descr="this is a testing param X",
(* how many extra argument must be provided by a user? *)
extra=1,
(* callback sets up the option and returns it *)
callback=(fun opts arg -> {opts with optX=(int) arg.[0]}),
(* use a short option style -x *)
short="-x"
);

(* This option can be specified with -y. There is no extra argument. This
option just sets a flag, optY. *)
Option ((* description of the option *)
descr="this is a testing param Y",
(* set the option to be true *)
callback=(fun opts _ -> {opts with optY=true}),
(* use a short option style (-y) *)
short="-y",
(* also use a long option style (--yoohoo) *)
long="--yoohoo"
);

(* A dummy option to pretty-print the usage *)
Option ((* description of the option *)
descr="",
dummy=true
);
Option ((* description of the option *)
descr="[Required Options]",
descrColor=System.ConsoleColor.DarkCyan,
dummy=true
);

(* The third option is a required option. In other words, option parsing
will raise an exception if this option is not given by a user. This
option takes in an additional integer argument, and set it to the global
variable z. *)
Option ((* description of the option *)
descr="required parameter <STRING> with an integer option",
(* callback to set the optZ value *)
callback=(fun opts arg -> {opts with optZ=arg.[0]}),
(* specifying this is a required option *)
required=true,
(* one additional argument to specify an integer value *)
extra=1,
(* use only a long option style *)
long="--req"
);
]

let _ =
let prog = "opttest.fsx"
let args = System.Environment.GetCommandLineArgs ()
let usageGetter () = "[Usage]\n %p %o"
try
let left, opts = optParse spec usageGetter prog args defaultOpts
printfn "Rest args: %A, x: %d, y: %b, z: %s"
left opts.optX opts.optY opts.optZ
0
with
| SpecErr msg ->
eprintfn "Invalid spec: %s" msg
exit 1
| RuntimeErr msg ->
eprintfn "Invalid args given by user: %s" msg
usagePrint spec prog usageGetter (fun () -> exit 1)
diff --git a/2024/06/27/OCaml-News-2024-5/index.html b/2024/06/27/OCaml-News-2024-5/index.html index 198d695e..6b45e5ad 100644 --- a/2024/06/27/OCaml-News-2024-5/index.html +++ b/2024/06/27/OCaml-News-2024-5/index.html @@ -192,58 +192,70 @@
-

语言的发展

diff --git "a/2024/06/27/\344\272\214\343\200\207\344\272\214\345\233\233\345\271\264\345\205\255\346\234\210\344\272\214\345\215\201\344\270\203\346\227\245/index.html" "b/2024/06/27/\344\272\214\343\200\207\344\272\214\345\233\233\345\271\264\345\205\255\346\234\210\344\272\214\345\215\201\344\270\203\346\227\245/index.html" index ebfa85b1..903b3aaf 100644 --- "a/2024/06/27/\344\272\214\343\200\207\344\272\214\345\233\233\345\271\264\345\205\255\346\234\210\344\272\214\345\215\201\344\270\203\346\227\245/index.html" +++ "b/2024/06/27/\344\272\214\343\200\207\344\272\214\345\233\233\345\271\264\345\205\255\346\234\210\344\272\214\345\215\201\344\270\203\346\227\245/index.html" @@ -184,7 +184,11 @@
-

钟摆晃荡 走出时间,
面包屑洒了一地 变成星空,
玻璃杯留下的牛奶唇印、折射出极光,
​狂犬症发病具有潜伏期,
宇宙说它也会倦怠、凋落,

+

钟摆晃荡 走出时间,
+面包屑洒了一地 变成星空,
+玻璃杯留下的牛奶唇印、折射出极光,
+​狂犬症发病具有潜伏期,
+宇宙说它也会倦怠、凋落,

身后伟岸的森林倒下了,我最大的遗失是没有了后悔的权利,我的忽视酿成了天地两别再无可相见的结局。

我的眼睛面积一定小于湖,我也很少哭,你若坐在我面前,就像站在湖边,细细的雾水就扯着地连着天。

-- cgit v1.2.3