From c2cb80e7942570337c154d310d52c31956de9ca6 Mon Sep 17 00:00:00 2001 From: Justin Ma Date: Tue, 30 Aug 2022 00:46:43 +0800 Subject: [PATCH] Update Chinese translation of README.md (#1325) --- README.中文.md | 282 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 206 insertions(+), 76 deletions(-) diff --git a/README.中文.md b/README.中文.md index f8a0026..47917d9 100644 --- a/README.中文.md +++ b/README.中文.md @@ -101,72 +101,146 @@ list: ### 安装包 -| 操作系统 | 包管理器 | 安装包 | 命令 | -| ---------------------------------------------------- | ------------------------- | ------------------------------------------------ | --------------------------------------------------------------------------------------- | -| [Various][rust-platforms] | [Cargo][cargo] | [just][just-crate] | `cargo install just` | -| [Microsoft Windows][windows] | [Scoop][scoop] | [just][just-scoop] | `scoop install just` | -| [Various][homebrew-install] | [Homebrew][homebrew] | [just][just-homebrew] | `brew install just` | -| [macOS][macos] | [MacPorts][macports] | [just][just-macports] | `port install just` | -| [Arch Linux][arch linux] | [pacman][pacman] | [just][just-pacman] | `pacman -S just` | -| [Various][nix-platforms] | [Nix][nix] | [just][just-nixpkg] | `nix-env -iA nixpkgs.just` | -| [NixOS][nixos] | [Nix][nix] | [just][just-nixpkg] | `nix-env -iA nixos.just` | -| [Solus][solus] | [eopkg][solus-eopkg] | [just][just-solus] | `eopkg install just` | -| [Void Linux][void linux] | [XBPS][xbps] | [just][just-void] | `xbps-install -S just` | -| [FreeBSD][freebsd] | [pkg][freebsd-pkg] | [just][just-freebsd] | `pkg install just` | -| [Alpine Linux][alpine linux] | [apk-tools][apk-tools] | [just][just-alpine] | `apk add just` | -| [Fedora Linux][fedora linux] | [DNF][dnf] | [just][just-fedora] | `dnf install just` | -| [Gentoo Linux][gentoo linux] | [Portage][gentoo-portage] | [dm9pZCAq overlay: sys-devel/just][just-portage] | `eselect repository enable dm9pZCAq && emerge --sync dm9pZCAq && emerge sys-devel/just` | -| [Various][conda-platforms] | [Conda][conda] | [just][just-conda] | `conda install -c conda-forge just` | -| [Microsoft Windows][windows] | [Chocolatey][chocolatey] | [just][just-chocolatey] | `choco install just` | -| [Various][snap-platforms] | [Snap][snap] | [just][just-snap] | `snap install --edge --classic just` | - -[alpine linux]: https://alpinelinux.org -[apk-tools]: https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management -[arch linux]: https://www.archlinux.org -[cargo]: https://www.rust-lang.org -[chocolatey]: https://chocolatey.org -[conda-platforms]: https://docs.conda.io/en/latest/miniconda.html#system-requirements -[conda]: https://docs.conda.io/projects/conda/en/latest/index.html -[dnf]: https://dnf.readthedocs.io/en/latest/ -[fedora linux]: https://getfedora.org -[freebsd-pkg]: https://www.freebsd.org/doc/handbook/pkgng-intro.html -[freebsd]: https://www.freebsd.org -[gentoo linux]: https://www.gentoo.org -[gentoo-portage]: https://wiki.gentoo.org/wiki/Portage -[homebrew-install]: https://docs.brew.sh/Installation -[homebrew]: https://brew.sh -[just-alpine]: https://pkgs.alpinelinux.org/package/edge/community/x86_64/just -[just-chocolatey]: https://github.com/michidk/just-choco -[just-conda]: https://anaconda.org/conda-forge/just -[just-crate]: https://crates.io/crates/just -[just-fedora]: https://src.fedoraproject.org/rpms/rust-just -[just-freebsd]: https://www.freshports.org/deskutils/just/ -[just-homebrew]: https://formulae.brew.sh/formula/just -[just-macports]: https://ports.macports.org/port/just/summary -[just-nixpkg]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/tools/just/default.nix -[just-pacman]: https://archlinux.org/packages/community/x86_64/just/ -[just-portage]: https://github.com/gentoo-mirror/dm9pZCAq/tree/master/sys-devel/just -[just-scoop]: https://github.com/ScoopInstaller/Main/blob/master/bucket/just.json -[just-snap]: https://snapcraft.io/just -[just-solus]: https://dev.getsol.us/source/just/ -[just-void]: https://github.com/void-linux/void-packages/blob/master/srcpkgs/just/template -[macos]: https://en.wikipedia.org/wiki/MacOS -[macports]: https://www.macports.org -[nix-plat]: https://nixos.org/nix/manual/#ch-supported-platforms -[nix-platforms]: https://nixos.org/download.html#download-nix -[nix]: https://nixos.org/nix/ -[nixos]: https://nixos.org/nixos/ -[pacman]: https://wiki.archlinux.org/title/Pacman -[rust-platforms]: https://forge.rust-lang.org/release/platform-support.html -[scoop]: https://scoop.sh -[snap-platforms]: https://snapcraft.io/docs/installing-snapd -[snap]: https://snapcraft.io -[solus-eopkg]: https://getsol.us/articles/package-management/basics/en -[solus]: https://getsol.us -[ubuntu]: https://ubuntu.com -[void linux]: https://voidlinux.org -[windows]: https://en.wikipedia.org/wiki/Microsoft_Windows -[xbps]: https://wiki.voidlinux.org/XBPS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
操作系统包管理器安装包命令
VariousCargojustcargo install just
Microsoft WindowsScoopjustscoop install just
VariousHomebrewjustbrew install just
macOSMacPortsjustport install just
Arch Linuxpacmanjustpacman -S just
VariousNixjustnix-env -iA nixpkgs.just
NixOSNixjustnix-env -iA nixos.just
Soluseopkgjusteopkg install just
Void LinuxXBPSjustxbps-install -S just
FreeBSDpkgjustpkg install just
Alpine Linuxapk-toolsjustapk add just
Fedora LinuxDNFjustdnf install just
Gentoo LinuxPortagedm9pZCAq/sys-devel/just + eselect repository enable dm9pZCAq
+ emerge --sync dm9pZCAq
+ emerge sys-devel/just +
VariousCondajustconda install -c conda-forge just
Microsoft WindowsChocolateyjustchoco install just
VariousSnapjustsnap install --edge --classic just
Variousasdfjust + asdf plugin add just
+ asdf install just <version> +
Debian and Ubuntu derivativesMPRjust + git clone 'https://mpr.makedeb.org/just'
+ cd just
+ makedeb -si +
Debian and Ubuntu derivativesPrebuilt-MPRjust + You must have the Prebuilt-MPR set up on your system in order to run this command.
+ sudo apt install just +
![package version table](https://repology.org/badge/vertical-allrepos/just.svg) @@ -215,7 +289,7 @@ just --help ### Node.js 安装 -[just-install](https://npmjs.com/packages/just-install) 可用于在 Node.js 应用程序中自动安装 `just`。 +[just-install](https://npmjs.com/package/just-install) 可用于在 Node.js 应用程序中自动安装 `just`。 `just` 是一个很赞的比 npm 脚本更强大的替代品。如果你想在 Node.js 应用程序的依赖中包含 `just`,可以通过 `just-install`,它将在本机安装一个针对特定平台的二进制文件作为 `npm install` 安装结果的一部分。这样就不需要每个开发者使用上述提到的步骤独立安装 `just`。安装后,`just` 命令将在 npm 脚本或 npx 中工作。这对那些想让项目的设置过程尽可能简单的团队来说是很有用的。 @@ -501,6 +575,8 @@ default: @just --list ``` +请注意,你可能需要在上面这一行中添加 `--justfile {{justfile()}}`。没有它,如果你执行 `just -f /some/distant/justfile -d .` 或 `just -f ./non-standard-justfile` 配方中的普通 `just --list` 就不一定会使用你提供的文件,它将试图在你的当前路径中找到一个 `justfile`,甚至可能导致 `No justfile found` 的错误。 + 标题文本可以用 `--list-heading` 来定制: ```sh @@ -561,14 +637,15 @@ foo: #### 设置一览表 -| 名称 | 值 | 描述 | -| ------------------------- | ------------------ | ------------------------------------------------------ | -| `allow-duplicate-recipes` | boolean | 允许在 `justfile` 后面出现的配方覆盖之前的同名配方 | -| `dotenv-load` | boolean | 加载 `.env` 环境变量文件, 如果有的话 | -| `export` | boolean | 将所有变量导出为环境变量 | -| `positional-arguments` | boolean | 传递位置参数 | -| `shell` | `[COMMAND, ARGS…]` | 设置用于调用配方和评估反引号内包裹内容的命令 | -| `windows-powershell` | boolean | 在 Windows 上使用 PowerShell 作为默认 Shell | +| 名称 | 值 | 描述 | +| ------------------------- | ------------------ | --------------------------------------------------------------------------- | +| `allow-duplicate-recipes` | boolean | 允许在 `justfile` 后面出现的配方覆盖之前的同名配方 | +| `dotenv-load` | boolean | 加载 `.env` 环境变量文件, 如果有的话 | +| `export` | boolean | 将所有变量导出为环境变量 | +| `positional-arguments` | boolean | 传递位置参数 | +| `shell` | `[COMMAND, ARGS…]` | 设置用于调用配方和评估反引号内包裹内容的命令 | +| `windows-shell` | `[COMMAND, ARGS…]` | 设置用于调用配方和评估反引号内包裹内容的命令。 | +| `windows-powershell` | boolean | 在 Windows 上使用 PowerShell 作为默认 Shell(废弃,建议使用 `windows-shell`) | Bool 类型设置可以写成: @@ -695,6 +772,8 @@ hello: Write-Host "Hello, world!" ``` +参考 [powershell.just](https://github.com/casey/just/blob/master/examples/powershell.just) ,了解在所有平台上使用 PowerShell 的 justfile。 + ##### Windows PowerShell *`set windows-powershell` 使用遗留的 `powershell.exe` 二进制文件,不再推荐。请参阅上面的 `windows-shell` 设置,以通过更灵活的方式来控制在 Windows 上使用哪个 Shell。* @@ -1359,6 +1438,28 @@ build target: cd {{target}} && make ``` +变量也可以作为参数传递给依赖: + +```make +target := "main" + +_build version: + @echo 'Building {{version}}…' + cd {{version}} && make + +build: (_build target) +``` + +命令的参数可以通过将依赖与参数一起放在括号中的方式传递给依赖: + +```make +build target: + @echo "Building {{target}}…" + +push target: (build target) + @echo 'Pushing {{target}}…' +``` + 参数可以有默认值: ```make @@ -2035,6 +2136,17 @@ foo $argument: 这就破坏了 `just` 捕捉拼写错误的能力,例如你输入 `$argumant`,但对 `argument` 的所有可能的值都有效,包括那些带双引号的。 +### 配置 Shell + +有许多方法可以为行式配方配置 Shell,当配方不以 `#!` Shebang 开头时,这些配方的 Shell 为默认的。它们的优先级,从高到低为: + +1. `--shell` 和 `--shell-arg` 命令行选项。传入这两个选项中的任何一个,都会使 `just` 忽略当前 justfile 中的任何设置 +2. `set windows-shell := [...]` +3. `set windows-powershell` (废弃) +4. `set shell := [...]` + +由于 `set windows-shell` 比 `set shell` 有更高的优先级,你可以用 `set windows-shell` 在 Windows 上选择一个 Shell,而 `set shell` 则为所有其他平台选择一个 Shell。 + 更新日志 --------- @@ -2069,6 +2181,23 @@ Bash、Zsh、Fish、PowerShell 和 Elvish 的 Shell 自动补全脚本可以在 $ just --completions zsh > just.zsh ``` +*macOS 注意:* 最近版本的 macOS 使用 zsh 作为默认的 Shell。如果你使用 Homebrew 安装 `just`,它会自动安装 zsh 补全脚本的最新副本到 Homebrew zsh 目录下,而内置默认版本的 zsh 是不知道的。如果可能的话,最好使用这个脚本副本,因为当你通过 Homebrew 更新 `just` 时,它也会被更新。另外,许多其他的 Homebrew 软件包也使用相同位置的补全脚本,而内置的 zsh 也不知道这些。为了在这种情况下在 zsh 中使用 `just` 的补全,你可以在调用 `compinit` 之前将 `fpath` 设置为 Homebrew 的位置。还要注意,Oh My Zsh 默认会运行 `compinit`,所以你的 `.zshrc` 文件看起来像这样: + +```zsh +# 启动Homebrew,添加环境变量 +eval "$(brew shellenv)" + +fpath=($HOMEBREW_PREFIX/share/zsh/site-functions $fpath) + +# 然后从这些选项中选择一个: +# 1. 如果你使用的是 Oh My Zsh,你可以在这里初始化它 +# source $ZSH/oh-my-zsh.sh + +# 2. 否则就自己运行 compinit +# autoload -U compinit +# compinit +``` + ### 语法 在 [GRAMMAR.md](https://github.com/casey/just/blob/master/GRAMMAR.md) 中可以找到一个非正式的 `justfile` 语法说明。 @@ -2131,8 +2260,9 @@ export PATH := "./node_modules/.bin:" + env_var('PATH') 现在并不缺少命令运行器!在这里,有一些或多或少比较类似于 `just` 的替代方案,包括: +- [make](https://en.wikipedia.org/wiki/Make_(software)): 启发了 `just` 的 Unix 构建工具。 +- [makesure](https://github.com/xonixx/makesure): 一个用 AWK 和 Shell 编写的简单而便携的命令运行器。 - [mmake](https://github.com/tj/mmake): 一个围绕 `make` 的包装器,有很多改进,包括远程引入。 - - [robo](https://github.com/tj/robo): 一个用 Go 编写的基于 YAML 的命令运行器。 贡献