You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(unstable): Expand on manifest commands so far
This is written to reflect the current implementation though some parts
might read a little weird because I didn't want to write throw-away
documentation for when we change this. For example, single-file
packages are currently only supported in `cargo <command>` and not as
manifest paths but this will change.
A user may optionally specify a manifest in a `cargo` code fence in a module-level comment, like:
1410
+
```rust
1411
+
#!/usr/bin/envcargo
1412
+
1413
+
//! ```cargo
1414
+
//! [dependencies]
1415
+
//! clap = { version = "4.2", features = ["derive"] }
1416
+
//! ```
1417
+
1418
+
useclap::Parser;
1419
+
1420
+
#[derive(Parser, Debug)]
1421
+
#[clap(version)]
1422
+
structArgs {
1423
+
#[clap(short, long, help ="Path to config")]
1424
+
config:Option<std::path::PathBuf>,
1425
+
}
1426
+
1427
+
fnmain() {
1428
+
letargs=Args::parse();
1429
+
println!("{:?}", args);
1430
+
}
1431
+
```
1432
+
1433
+
#### Single-file packages
1434
+
1435
+
In addition to today's multi-file packages (`Cargo.toml` file with other `.rs`
1436
+
files), we are adding the concept of single-file packages which may contain an
1437
+
embedded manifest. There is no required distinguishment for a single-file
1438
+
`.rs` package from any other `.rs` file.
1439
+
1440
+
A single-file package may contain an embedded manifest. An embedded manifest
1441
+
is stored using `TOML` in a markdown code-fence with `cargo` at the start of the
1442
+
infostring inside a target-level doc-comment. It is an error to have multiple
1443
+
`cargo` code fences in the target-level doc-comment. We can relax this later,
1444
+
either merging the code fences or ignoring later code fences.
1445
+
1446
+
Supported forms of embedded manifest are:
1447
+
``````rust
1448
+
//! ```cargo
1449
+
//! ```
1450
+
``````
1451
+
``````rust
1452
+
/*!
1453
+
* ```cargo
1454
+
* ```
1455
+
*/
1456
+
``````
1457
+
1458
+
Inferred / defaulted manifest fields:
1459
+
-`package.name = <slugified file stem>`
1460
+
-`package.version = "0.0.0"` to [call attention to this crate being used in unexpected places](https://matklad.github.io/2021/08/22/large-rust-workspaces.html#Smaller-Tips)
1461
+
-`package.publish = false` to avoid accidental publishes, particularly if we
1462
+
later add support for including them in a workspace.
1463
+
-`package.edition = <current>` to avoid always having to add an embedded
1464
+
manifest at the cost of potentially breaking scripts on rust upgrades
1465
+
- Warn when `edition` is unspecified. While with single-file packages this will be
1466
+
silenced by default, users wanting stability are also likely to be using
1467
+
other commands, like `cargo test` and will see it.
0 commit comments