feat(stdlib): Mid M5 list algorithms and cli.parse
Thicken table with sort/unique/chunk/zip/flatten and add lib/cli flag parsing, with golds and public demos. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
506de65dae
commit
7d86ed1d9c
20 files changed
+608
-14
No files matched your search
@@ -0,0 +1,11 @@
|
||||
---
|
||||
title: lib/cli
|
||||
description: Parse argv flags (Mid M5). --key value / --key=value / --flag; positionals under _.
|
||||
---
|
||||
|
||||
## parse
|
||||
+ `args`=None
|
||||
|
||||
Parse `--key value` / `--key=value` / `--flag`. A bare `--flag` must not be followed by a non-option token if you need it as boolean (put flags last, or use `--flag=true`). Positionals land under `_`.
|
||||
|
||||
**> host_cli_parse args=`args`**
|
||||
@@ -129,6 +129,49 @@ Zero-based index or `None`.
|
||||
|
||||
**> host_list_reverse list=`list`**
|
||||
|
||||
## sort
|
||||
+ `list`
|
||||
|
||||
Ascending sort (int/num/text preferred).
|
||||
|
||||
**> host_list_sort list=`list`**
|
||||
|
||||
## sort_by
|
||||
+ `list`
|
||||
+ `key`
|
||||
|
||||
Sort a list of maps by `key`.
|
||||
|
||||
**> host_list_sort_by list=`list` key=`key`**
|
||||
|
||||
## unique
|
||||
+ `list`
|
||||
|
||||
Stable unique (first wins).
|
||||
|
||||
**> host_list_unique list=`list`**
|
||||
|
||||
## chunk
|
||||
+ `list`
|
||||
+ `size`
|
||||
|
||||
**> host_list_chunk list=`list` size=`size`**
|
||||
|
||||
## zip
|
||||
+ `a`
|
||||
+ `b`
|
||||
|
||||
Pairs until the shorter list ends.
|
||||
|
||||
**> host_list_zip a=`a` b=`b`**
|
||||
|
||||
## flatten
|
||||
+ `list`
|
||||
|
||||
One-level flatten.
|
||||
|
||||
**> host_list_flatten list=`list`**
|
||||
|
||||
## clear
|
||||
+ `value`
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
---
|
||||
title: lib/命令行
|
||||
description: 解析命令行参数(中层 M5)。--键 值 / --键=值 / --开关;位置参在 _。
|
||||
---
|
||||
|
||||
## 解析
|
||||
+ `参数`=None
|
||||
|
||||
省略 `参数` 时用进程 argv(系统.参数表)。
|
||||
|
||||
**> host_cli_parse args=`参数`**
|
||||
+43
@@ -129,6 +129,49 @@ description: >-
|
||||
|
||||
**> host_list_reverse list=`list`**
|
||||
|
||||
## 排序
|
||||
+ `list`
|
||||
|
||||
升序(优先 int/num/text)。
|
||||
|
||||
**> host_list_sort list=`list`**
|
||||
|
||||
## 按键排序
|
||||
+ `list`
|
||||
+ `key`
|
||||
|
||||
对 map 列表按键排序。
|
||||
|
||||
**> host_list_sort_by list=`list` key=`key`**
|
||||
|
||||
## 去重
|
||||
+ `list`
|
||||
|
||||
保序去重(保留首次)。
|
||||
|
||||
**> host_list_unique list=`list`**
|
||||
|
||||
## 分块
|
||||
+ `list`
|
||||
+ `size`
|
||||
|
||||
**> host_list_chunk list=`list` size=`size`**
|
||||
|
||||
## 拉链
|
||||
+ `a`
|
||||
+ `b`
|
||||
|
||||
取较短长度配对。
|
||||
|
||||
**> host_list_zip a=`a` b=`b`**
|
||||
|
||||
## 展平
|
||||
+ `list`
|
||||
|
||||
一层展平。
|
||||
|
||||
**> host_list_flatten list=`list`**
|
||||
|
||||
## 清空
|
||||
+ `value`
|
||||
|
||||
|
||||
Reference in new issue
Block a user