1
1
mirror of https://github.com/casey/just.git synced 2024-11-22 10:26:26 +03:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Justin Ma
98a1ad6627
Translate first section of readme into Chinese (#1205)
Based on commit 95de4eb,
2022-05-28 20:04:54 -07:00
Casey Rodarmor
c87909c220
Fix a bunch of typos (#1204) 2022-05-29 02:07:53 +00:00
17 changed files with 253 additions and 31 deletions

View File

@ -627,7 +627,7 @@ Changelog
- Avoid fs::canonicalize (#539)
### Misc
- Mention `set shell` as altenative to installing `sh` (#533)
- Mention `set shell` as alternative to installing `sh` (#533)
- Refactor Compilation error to contain a Token (#535)
- Move lexer comment (#536)
- Add missing `--init` test (#543)

222
README.中文.md Normal file
View File

@ -0,0 +1,222 @@
↖️ 目录
<h1 align="center"><code>just</code></h1>
<div align="center">
<a href="https://crates.io/crates/just">
<img src="https://img.shields.io/crates/v/just.svg" alt="crates.io version">
</a>
<a href="https://github.com/casey/just/actions">
<img src="https://github.com/casey/just/workflows/Build/badge.svg" alt="build status">
</a>
<a href="https://github.com/casey/just/releases">
<img src="https://img.shields.io/github/downloads/casey/just/total.svg" alt="downloads">
</a>
<a href="https://discord.gg/ezYScXR">
<img src="https://img.shields.io/discord/695580069837406228?logo=discord" alt="chat on discord">
</a>
<a href="mailto:casey@rodarmor.com?subject=Thanks%20for%20Just!">
<img src="https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg" alt="say thanks">
</a>
</div>
<br>
`just` 为您提供一种保存和运行项目特有命令的便捷方式。
本指南同时也以 [](https://just.systems/man/) 的形式在线阅读;
命令,在此也称为配方,存储在一个名为 `justfile` 的文件中,其语法受 `make` 启发:
![screenshot](screenshot.png)
然后你可以用 `just RECIPE` 运行它们:
```sh
$ just test-all
cc *.c -o main
./test --all
Yay, all your tests passed!
```
`just` 有很多很棒的特性,而且相比 `make` 有很多改进:
- `just` 是一个命令运行器,而不是一个构建系统,所以它避免了许多 [`make` 的复杂性和特异性](#what-are-theidiosyncrasies-of-make-that-just-avoids)。不需要 `.PHONY` 配方!
- 支持 Linux、MacOS 和 Windows而且无需额外的依赖。(尽管如果你的系统没有 `sh`,你需要 [选择一个不同的 Shell](#shell))。
- 错误具体且富有参考价值,语法错误将会与产生它们的上下文一起被报告。
- 配方可以接受 [命令行参数](#配方参数)。
- 错误会尽可能被静态地解决。未知的配方和循环依赖关系会在运行之前被报告。
- `just` 可以 [加载`.env`文件](#dotenv-integration),简化环境变量注入。
- 配方可以在 [命令行中列出](#listing-available-recipes)。
- 命令行自动补全脚本 [支持大多数流行的 Shell](#shell-completion-scripts)。
- 配方可以用 [任意语言](#writing-recipes-in-other-languages) 编写,如 Python 或 NodeJS。
- `just` 可以从任何子目录中调用,而不仅仅是包含 `justfile` 的目录。
- 不仅如此,还有 [更多](https://just.systems/man/)
如果你在使用 `just` 方面需要帮助,请随时创建一个 Issue 或在[Discord](https://discord.gg/ezYScXR)上与我联系。我们随时欢迎功能请求和错误报告!
安装
------------
### 预备知识
`just` 应该可以在任何有合适的 `sh` 的系统上运行包括Linux、MacOS 和 BSD。
在 Windows 上,`just` 可以使用 [Git for Windows](https://git-scm.com)、[GitHub Desktop](https://desktop.github.com) 或 [Cygwin](http://www.cygwin.com) 所提供的 `sh`
如果你不愿意安装 `sh`,也可以使用 `shell` 设置来指定你选择的 Shell。
比如 PowerShell
```make
# 使用 PowerShell 替代 sh:
set shell := ["powershell.exe", "-c"]
hello:
Write-Host "Hello, world!"
```
…或者 `cmd.exe`:
```make
# 使用 cmd.exe 替代 sh:
set shell := ["cmd.exe", "/c"]
list:
dir
```
你也可以使用命令行参数来设置 Shell。例如若要使用PowerShell 也可以用 `--shell powershell.exe --shell-arg -c` 启动`just`。
(PowerShell 默认安装在 Windows 7 SP1 和 Windows Server 2008 R2 S1 及更高版本上,而 `cmd.exe` 相当麻烦所以PowerShell 被推荐给大多数 Windows 用户)
### 安装包
| 操作系统 | 包管理器 | 安装包 | 命令 |
| ---------------------------------------------------- | ------------------------- | ------------------------------------------------ | --------------------------------------------------------------------------------------- |
| [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` |
[rust-platforms]: https://forge.rust-lang.org/release/platform-support.html
[cargo]: https://www.rust-lang.org
[just-crate]: https://crates.io/crates/just
[windows]: https://en.wikipedia.org/wiki/Microsoft_Windows
[scoop]: https://scoop.sh
[just-scoop]: https://github.com/ScoopInstaller/Main/blob/master/bucket/just.json
[homebrew-install]: https://docs.brew.sh/Installation
[homebrew]: https://brew.sh
[just-homebrew]: https://formulae.brew.sh/formula/just
[macos]: https://en.wikipedia.org/wiki/MacOS
[macports]: https://www.macports.org
[just-macports]: https://ports.macports.org/port/just/summary
[arch linux]: https://www.archlinux.org
[nix-platforms]: https://nixos.org/download.html#download-nix
[pacman]: https://wiki.archlinux.org/title/Pacman
[just-pacman]: https://archlinux.org/packages/community/x86_64/just/
[nixos]: https://nixos.org/nixos/
[nix-plat]: https://nixos.org/nix/manual/#ch-supported-platforms
[nix]: https://nixos.org/nix/
[just-nixpkg]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/tools/just/default.nix
[solus]: https://getsol.us/
[solus-eopkg]: https://getsol.us/articles/package-management/basics/en
[just-solus]: https://dev.getsol.us/source/just/
[void linux]: https://voidlinux.org
[xbps]: https://wiki.voidlinux.org/XBPS
[just-void]: https://github.com/void-linux/void-packages/blob/master/srcpkgs/just/template
[freebsd]: https://www.freebsd.org/
[freebsd-pkg]: https://www.freebsd.org/doc/handbook/pkgng-intro.html
[just-freebsd]: https://www.freshports.org/deskutils/just/
[alpine linux]: https://alpinelinux.org/
[apk-tools]: https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management
[just-alpine]: https://pkgs.alpinelinux.org/package/edge/community/x86_64/just
[fedora linux]: https://getfedora.org/
[dnf]: https://dnf.readthedocs.io/en/latest/
[just-fedora]: https://src.fedoraproject.org/rpms/rust-just
[gentoo linux]: https://www.gentoo.org/
[gentoo-portage]: https://wiki.gentoo.org/wiki/Portage
[just-portage]: https://github.com/gentoo-mirror/dm9pZCAq/tree/master/sys-devel/just
[conda-platforms]: https://docs.conda.io/en/latest/miniconda.html#system-requirements
[conda]: https://docs.conda.io/projects/conda/en/latest/index.html
[just-conda]: https://anaconda.org/conda-forge/just
[chocolatey]: https://chocolatey.org
[just-chocolatey]: https://github.com/michidk/just-choco
![package version table](https://repology.org/badge/vertical-allrepos/just.svg)
### 预制二进制文件
Linux、MacOS 和 Windows 的预制二进制文件可以在 [发布页](https://github.com/casey/just/releases) 上找到。
你也可以在 Linux、MacOS 或 Windows 上使用下面的命令来下载最新的版本,只需将 `DEST` 替换为你想存储 `just` 的目录:
```sh
curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to DEST
```
例如,安装 `just``~/bin` 目录:
```sh
# 创建 ~/bin
mkdir -p ~/bin
# 下载并解压 just 到 ~/bin/just
curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to ~/bin
# 在 Shell 搜索可执行文件的路径中添加`~/bin`
# 这一行应该被添加到你的 Shell 初始化文件中e.g. `~/.bashrc` 或者 `~/.zshrc`
export PATH="$PATH:$HOME/bin"
# 现在 just 应该就可以执行了
just --help
```
### GitHub Actions
[extractions/setup-just](https://github.com/extractions/setup-just) 可以用来在 GitHub Actions 的工作流程中安装 `just`
使用举例:
```yaml
- uses: extractions/setup-just@v1
with:
just-version: 0.8 # optional semver specification, otherwise latest
```
### 发布 RSS 订阅
`just` 的发布 [RSS 订阅](https://en.wikipedia.org/wiki/RSS) 可以在 [这里](https://github.com/casey/just/releases.atom) 找到。
向后兼容性
-----------------------
随着1.0版本的发布,`just` 突出对向后兼容性和稳定性的强烈承诺。
未来的版本将不会引入向后不兼容的变化,不会使现有的 `justfile` 停止工作,或破坏命令行界面的正常调用。
然而,这并不排除错误修复,即使这样做可能会破坏依赖其行为的 `justfiles`
永远不会有一个 `just` 2.0。任何理想的向后兼容的变化都是在每个 `justfile` 的基础上选择性加入的,所以用户可以在他们的闲暇时间进行迁移。
还没有准备好稳定化的功能将在 `--unstable` 标志后被选择性启用。由`--unstable`启用的功能可能会在任何时候以不兼容的方式发生变化。

View File

@ -33,7 +33,7 @@ build:
fmt:
cargo fmt --all
watch +COMMAND='ltest':
watch +COMMAND='test':
cargo watch --clear --exec "{{COMMAND}}"
man:

View File

@ -295,7 +295,7 @@ mod tests {
}
analysis_error! {
name: parameter_shadows_varible,
name: parameter_shadows_variable,
input: "foo := \"h\"\na foo:",
offset: 13,
line: 1,

View File

@ -101,7 +101,7 @@ impl<'src: 'run, 'run> AssignmentResolver<'src, 'run> {
self.resolve_expression(c)
}
},
Expression::Concatination { lhs, rhs } => {
Expression::Concatenation { lhs, rhs } => {
self.resolve_expression(lhs)?;
self.resolve_expression(rhs)
}

View File

@ -665,7 +665,7 @@ mod tests {
let app = Config::app();
let matches = app
.get_matches_from_safe(arguments)
.expect("agument parsing failed");
.expect("argument parsing failed");
let have = Config::from_matches(&matches).expect("config parsing failed");
assert_eq!(have, want);
}
@ -702,7 +702,7 @@ mod tests {
let app = Config::app();
let matches = app.get_matches_from_safe(arguments).expect("Matching failes");
let matches = app.get_matches_from_safe(arguments).expect("Matching fails");
match Config::from_matches(&matches).expect_err("config parsing succeeded") {
$error => { $($check)? }

View File

@ -150,7 +150,7 @@ impl<'src, 'run> Evaluator<'src, 'run> {
Ok(self.run_backtick(contents, token)?)
}
}
Expression::Concatination { lhs, rhs } => {
Expression::Concatenation { lhs, rhs } => {
Ok(self.evaluate_expression(lhs)? + &self.evaluate_expression(rhs)?)
}
Expression::Conditional {

View File

@ -16,7 +16,7 @@ pub(crate) enum Expression<'src> {
/// `name(arguments)`
Call { thunk: Thunk<'src> },
/// `lhs + rhs`
Concatination {
Concatenation {
lhs: Box<Expression<'src>>,
rhs: Box<Expression<'src>>,
},
@ -46,7 +46,7 @@ impl<'src> Display for Expression<'src> {
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
match self {
Expression::Backtick { token, .. } => write!(f, "{}", token.lexeme()),
Expression::Concatination { lhs, rhs } => write!(f, "{} + {}", lhs, rhs),
Expression::Concatenation { lhs, rhs } => write!(f, "{} + {}", lhs, rhs),
Expression::Conditional {
lhs,
rhs,
@ -79,7 +79,7 @@ impl<'src> Serialize for Expression<'src> {
seq.end()
}
Self::Call { thunk } => thunk.serialize(serializer),
Self::Concatination { lhs, rhs } => {
Self::Concatenation { lhs, rhs } => {
let mut seq = serializer.serialize_seq(None)?;
seq.serialize_element("concatinate")?;
seq.serialize_element(lhs)?;

View File

@ -970,7 +970,7 @@ f x=`echo hello`:
}
test! {
parameter_default_concatination_string,
parameter_default_concatenation_string,
r#"
f x=(`echo hello` + "foo"):
"#,
@ -978,7 +978,7 @@ f x=(`echo hello` + "foo"):
}
test! {
parameter_default_concatination_variable,
parameter_default_concatenation_variable,
r#"
x := "10"
f y=(`echo hello` + x) +z="foo":
@ -1000,7 +1000,7 @@ f y=(`echo hello` + x) +z=("foo" + "bar"):"#,
}
test! {
concatination_in_group,
concatenation_in_group,
"x := ('0' + '1')",
"x := ('0' + '1')",
}

View File

@ -1107,7 +1107,7 @@ mod tests {
}
test! {
name: export_concatination,
name: export_concatenation,
text: "export foo = 'foo' + 'bar'",
tokens: (
Identifier:"export",

View File

@ -1,6 +1,6 @@
use crate::common::*;
/// Methods commmon to all AST nodes. Currently only used in parser unit tests.
/// Methods common to all AST nodes. Currently only used in parser unit tests.
pub(crate) trait Node<'src> {
/// Construct an untyped tree of atoms representing this Node. This function,
/// and `Tree` type, are only used in parser unit tests.
@ -52,7 +52,7 @@ impl<'src> Node<'src> for Assignment<'src> {
impl<'src> Node<'src> for Expression<'src> {
fn tree(&self) -> Tree<'src> {
match self {
Expression::Concatination { lhs, rhs } => Tree::atom("+").push(lhs.tree()).push(rhs.tree()),
Expression::Concatenation { lhs, rhs } => Tree::atom("+").push(lhs.tree()).push(rhs.tree()),
Expression::Conditional {
lhs,
rhs,

View File

@ -40,7 +40,7 @@ impl<'tokens, 'src> Parser<'tokens, 'src> {
Self::new(tokens).parse_ast()
}
/// Construct a new Paser from a token stream
/// Construct a new Parser from a token stream
fn new(tokens: &'tokens [Token<'src>]) -> Parser<'tokens, 'src> {
Parser {
next: 0,
@ -399,7 +399,7 @@ impl<'tokens, 'src> Parser<'tokens, 'src> {
if self.accepted(Plus)? {
let lhs = Box::new(value);
let rhs = Box::new(self.parse_expression()?);
Ok(Expression::Concatination { lhs, rhs })
Ok(Expression::Concatenation { lhs, rhs })
} else {
Ok(value)
}
@ -1107,7 +1107,7 @@ mod tests {
}
test! {
name: recipe_dependency_argument_concatination,
name: recipe_dependency_argument_concatenation,
text: "foo: (bar 'a' + 'b' 'c' + 'd')",
tree: (justfile (recipe foo (deps (bar (+ 'a' 'b') (+ 'c' 'd'))))),
}
@ -1341,7 +1341,7 @@ mod tests {
}
test! {
name: parameter_default_concatination_variable,
name: parameter_default_concatenation_variable,
text: r#"
x := "10"
@ -1636,7 +1636,7 @@ mod tests {
}
test! {
name: parameter_default_concatination_string,
name: parameter_default_concatenation_string,
text: r#"
f x=(`echo hello` + "foo"):
"#,
@ -1644,7 +1644,7 @@ mod tests {
}
test! {
name: concatination_in_group,
name: concatenation_in_group,
text: "x := ('0' + '1')",
tree: (justfile (assignment x ((+ "0" "1")))),
}
@ -1823,7 +1823,7 @@ mod tests {
}
test! {
name: conditional_concatinations,
name: conditional_concatenations,
text: "a := if b0 + b1 == c0 + c1 { d0 + d1 } else { e0 + e1 }",
tree: (justfile (assignment a (if (+ b0 b1) == (+ c0 c1) (+ d0 d1) (+ e0 e1)))),
}
@ -2039,7 +2039,7 @@ mod tests {
}
error! {
name: concatination_in_default,
name: concatenation_in_default,
input: "foo a=c+d e:",
offset: 10,
line: 0,

View File

@ -185,7 +185,7 @@ pub enum Expression {
name: String,
arguments: Vec<Expression>,
},
Concatination {
Concatenation {
lhs: Box<Expression>,
rhs: Box<Expression>,
},
@ -249,7 +249,7 @@ impl Expression {
arguments: vec![Expression::new(a), Expression::new(b), Expression::new(c)],
},
},
Concatination { lhs, rhs } => Expression::Concatination {
Concatenation { lhs, rhs } => Expression::Concatenation {
lhs: Box::new(Expression::new(lhs)),
rhs: Box::new(Expression::new(rhs)),
},

View File

@ -53,7 +53,7 @@ impl<'expression, 'src> Iterator for Variables<'expression, 'src> {
self.stack.push(lhs);
}
Expression::Variable { name, .. } => return Some(name.token()),
Expression::Concatination { lhs, rhs } => {
Expression::Concatenation { lhs, rhs } => {
self.stack.push(rhs);
self.stack.push(lhs);
}

View File

@ -9,8 +9,8 @@ pub(crate) enum Verbosity {
}
impl Verbosity {
pub(crate) fn from_flag_occurrences(flag_occurences: u64) -> Self {
match flag_occurences {
pub(crate) fn from_flag_occurrences(flag_occurrences: u64) -> Self {
match flag_occurrences {
0 => Taciturn,
1 => Loquacious,
_ => Grandiloquent,

View File

@ -917,7 +917,7 @@ test! {
}
test! {
name: group_recipies,
name: group_recipes,
justfile: "
foo:
echo foo

View File

@ -1680,7 +1680,7 @@ foo x='bar':
}
test! {
name: default_concatination,
name: default_concatenation,
justfile: "
foo x=(`echo foo` + 'bar'):
echo {{x}}