@@ -76,7 +76,7 @@ use increment.nu *
7676# => name, or export `main` command.
7777```
7878
79- 如错误消息中很有帮助地提到的 ,您可以简单地将导出重命名为 ` main ` ,在这种情况下,导入时将采用模块的名称。编辑 ` increment.nu ` 文件:
79+ 就像错误消息中提到的那样 ,您可以简单地将导出重命名为 ` main ` ,在这种情况下,导入时将采用模块的名称。编辑 ` increment.nu ` 文件:
8080
8181``` nu
8282export def main []: int -> int {
@@ -208,11 +208,11 @@ export def by [amount: int]: int -> int {
208208
2092093 . 测试它:
210210
211- ``` nu
212- use range-into-list.nu
213- 1..5 | range-into-list | describe
214- # => list<int> (stream)
215- ```
211+ ``` nu
212+ use range-into-list.nu
213+ 1..5 | range-into-list | describe
214+ # => list<int> (stream)
215+ ```
216216
2172174 . 我们现在应该有一个包含以下内容的 ` my-utils ` 目录:
218218
@@ -234,17 +234,17 @@ export def by [amount: int]: int -> int {
234234
2352352 . 我们现在有一个带有两个子模块的 ` my-utils ` 模块。试试看:
236236
237- ``` nu
238- # 转到 my-utils 的父目录
239- cd ..
240- use my-utils *
241- 5 | increment by 4
242- # => 9
243-
244- let file_indices = 0..2..<10 | range-into-list
245- ls | select ...$file_indices
246- # => 返回目录中的第 1、3、5、7 和 9 个文件
247- ```
237+ ``` nu
238+ # 转到 my-utils 的父目录
239+ cd ..
240+ use my-utils *
241+ 5 | increment by 4
242+ # => 9
243+
244+ let file_indices = 0..2..<10 | range-into-list
245+ ls | select ...$file_indices
246+ # => Returns the 1st, 3rd, 5th, 7th, and 9th file in the directory
247+ ```
248248
249249在继续下一节之前,运行 ` scope modules ` 并查找 ` my-utils ` 模块。请注意,它本身没有命令;只有两个子模块。
250250
@@ -270,7 +270,7 @@ use my-utils *
270270
271271let file_indices = 0..2..<10 | range-into-list
272272ls / | sort-by modified | select ...$file_indices
273- # => 返回目录中从最旧到最新的第 1、3、5、7 和 9 个文件
273+ # => Returns the 1st, 3rd, 5th, 7th, and 9th file in the directory, oldest-to-newest
274274```
275275
276276再次运行 ` scope modules ` ,请注意子模块的所有命令都重新导出到 ` my-utils ` 模块中。
@@ -300,7 +300,7 @@ export use ./range-into-list.nu
300300use my-utils *
301301help my-utils
302302
303- # => 一组有用的实用函数
303+ # => A collection of helpful utility functions
304304```
305305
306306另请注意,由于 ` increment ` 和 ` range-into-list ` 的命令使用 ` export use ... ` 重新导出,这些命令也显示在主模块的帮助中。
@@ -325,7 +325,7 @@ export-env {
325325``` nu
326326use my-utils
327327$env.NU_MODULES_DIR
328- # => 返回目录名
328+ # => Returns the directory name
329329cd $env.NU_MODULES_DIR
330330```
331331
@@ -374,9 +374,9 @@ export def --env modules [] {
374374``` nu
375375use go.nu
376376go home
377- # => 有效
377+ # => Works
378378go modules
379- # => 错误: $env.NU_MODULES_DIR 未找到
379+ # => Error: $env.NU_MODULES_DIR is not found
380380```
381381
382382这不起作用,因为在这种情况下的 ` my-utils ` 没有被* 求值* ;它仅在导入 ` go.nu ` 模块时被* 解析* 。虽然这会将所有其他导出带入作用域,但它不会* 运行* ` export-env ` 块。
@@ -474,8 +474,8 @@ use is-alphanumeric.nu *
474474'Some punctuation?!' | str is-alphanumeric
475475# => false
476476'a' in (alpha-num-range)
477- # => 错误:
478- # => 帮助: `alpha-num-range` 既不是 Nushell 内置命令也不是已知的外部命令
477+ # => Error:
478+ # => help: `alpha-num-range` is neither a Nushell built-in or a known external command
479479```
480480
481481### 子模块的选择性导出
@@ -527,9 +527,9 @@ export use ./go.nu [home, modules]
527527``` nu
528528use my-utils *
529529home
530- # => 有效
530+ # => works
531531go home
532- # => 错误:命令未找到
532+ # => Error: command not found
533533```
534534
535535要将它们导出为 ` go home ` 和 ` go modules ` ,请对 ` my-utils/mod.nu ` 进行以下更改:
@@ -547,7 +547,7 @@ export module go {
547547use my-utils *
548548# => 如预期:
549549go home
550- # => 有效
550+ # => works
551551home
552- # => 错误:命令未找到
552+ # => Error: command not found
553553```
0 commit comments