Skip to content

Commit 6139956

Browse files
committed
docs: Document cargo script
1 parent 014c8ce commit 6139956

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+257
-197
lines changed

src/doc/man/cargo-run.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ Unlike {{man "cargo-test" 1}} and {{man "cargo-bench" 1}}, `cargo run` sets the
2222
working directory of the binary executed to the current working directory, same
2323
as if it was executed in the shell directly.
2424

25+
When running scripts, the process' [arg0](../../std/env/fn.args.html) will be set to the
26+
script's path on a best-effort basis.
27+
2528
## OPTIONS
2629

2730
{{> section-options-package }}

src/doc/man/cargo.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ cargo --- The Rust package manager
77
## SYNOPSIS
88

99
`cargo` [_options_] _command_ [_args_]\
10+
`cargo` [_options_] _script_ [_args_]\
1011
`cargo` [_options_] `--version`\
1112
`cargo` [_options_] `--list`\
1213
`cargo` [_options_] `--help`\
@@ -19,12 +20,25 @@ available at <https://rust-lang.org>.
1920

2021
_command_ may be one of:
2122
- built-in commands, see below
23+
- [script](#scripts)
2224
- [aliases]
2325
- [external tools]
2426

2527
[aliases]: ../reference/config.html#alias
2628
[external tools]: ../reference/external-tools.html#custom-subcommands
2729

30+
## SCRIPTS
31+
32+
A _script_ is distinguished from a _command_ or _alias_ by having path separators present or a `.rs` extension.
33+
These are Rust source files with an optional [manifest] embedded in the frontmatter.
34+
35+
`cargo` _script_ operate on system or user level, not project level.
36+
This means that the local [configuration discovery] is ignored.
37+
Instead, the configuration discovery begins at `$CARGO_HOME/config.toml`.
38+
39+
[manifest]: ../reference/manifest.html
40+
[configuration discovery]: ../reference/config.html#hierarchical-structure
41+
2842
## COMMANDS
2943

3044
### Build Commands
@@ -248,7 +262,11 @@ stable yet and may be subject to change.
248262
mkdir foo && cd foo
249263
cargo init .
250264

251-
6. Learn about a command's options and usage:
265+
6. Run a script
266+
267+
cargo task.rs --action
268+
269+
7. Learn about a command's options and usage:
252270

253271
cargo help clean
254272

src/doc/man/generated_txt/cargo-add.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,9 @@ OPTIONS
164164

165165
Manifest Options
166166
--manifest-path path
167-
Path to the Cargo.toml file. By default, Cargo searches for the
168-
Cargo.toml file in the current directory or any parent directory.
167+
Path to the Cargo.toml or cargo script file. By default, Cargo
168+
searches for the Cargo.toml file in the current directory or any
169+
parent directory.
169170

170171
-p spec, --package spec
171172
Add dependencies to only the specified package.

src/doc/man/generated_txt/cargo-bench.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,9 @@ OPTIONS
335335

336336
Manifest Options
337337
--manifest-path path
338-
Path to the Cargo.toml file. By default, Cargo searches for the
339-
Cargo.toml file in the current directory or any parent directory.
338+
Path to the Cargo.toml or cargo script file. By default, Cargo
339+
searches for the Cargo.toml file in the current directory or any
340+
parent directory.
340341

341342
--ignore-rust-version
342343
Ignore rust-version specification in packages.

src/doc/man/generated_txt/cargo-build.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,9 @@ OPTIONS
259259

260260
Manifest Options
261261
--manifest-path path
262-
Path to the Cargo.toml file. By default, Cargo searches for the
263-
Cargo.toml file in the current directory or any parent directory.
262+
Path to the Cargo.toml or cargo script file. By default, Cargo
263+
searches for the Cargo.toml file in the current directory or any
264+
parent directory.
264265

265266
--ignore-rust-version
266267
Ignore rust-version specification in packages.

src/doc/man/generated_txt/cargo-check.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,9 @@ OPTIONS
253253

254254
Manifest Options
255255
--manifest-path path
256-
Path to the Cargo.toml file. By default, Cargo searches for the
257-
Cargo.toml file in the current directory or any parent directory.
256+
Path to the Cargo.toml or cargo script file. By default, Cargo
257+
searches for the Cargo.toml file in the current directory or any
258+
parent directory.
258259

259260
--ignore-rust-version
260261
Ignore rust-version specification in packages.

src/doc/man/generated_txt/cargo-clean.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,9 @@ OPTIONS
104104

105105
Manifest Options
106106
--manifest-path path
107-
Path to the Cargo.toml file. By default, Cargo searches for the
108-
Cargo.toml file in the current directory or any parent directory.
107+
Path to the Cargo.toml or cargo script file. By default, Cargo
108+
searches for the Cargo.toml file in the current directory or any
109+
parent directory.
109110

110111
--locked
111112
Asserts that the exact same dependencies and versions are used as

src/doc/man/generated_txt/cargo-doc.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,9 @@ OPTIONS
228228

229229
Manifest Options
230230
--manifest-path path
231-
Path to the Cargo.toml file. By default, Cargo searches for the
232-
Cargo.toml file in the current directory or any parent directory.
231+
Path to the Cargo.toml or cargo script file. By default, Cargo
232+
searches for the Cargo.toml file in the current directory or any
233+
parent directory.
233234

234235
--ignore-rust-version
235236
Ignore rust-version specification in packages.

src/doc/man/generated_txt/cargo-fetch.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ OPTIONS
8181

8282
Manifest Options
8383
--manifest-path path
84-
Path to the Cargo.toml file. By default, Cargo searches for the
85-
Cargo.toml file in the current directory or any parent directory.
84+
Path to the Cargo.toml or cargo script file. By default, Cargo
85+
searches for the Cargo.toml file in the current directory or any
86+
parent directory.
8687

8788
--locked
8889
Asserts that the exact same dependencies and versions are used as

src/doc/man/generated_txt/cargo-fix.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,9 @@ OPTIONS
327327

328328
Manifest Options
329329
--manifest-path path
330-
Path to the Cargo.toml file. By default, Cargo searches for the
331-
Cargo.toml file in the current directory or any parent directory.
330+
Path to the Cargo.toml or cargo script file. By default, Cargo
331+
searches for the Cargo.toml file in the current directory or any
332+
parent directory.
332333

333334
--ignore-rust-version
334335
Ignore rust-version specification in packages.

0 commit comments

Comments
 (0)