Il L'opzione --manifest-path path/to/Cargo.toml
per quasi tutti i sottocomandi cargo
consente di indirizzarla a uno specifico file Cargo.toml
da utilizzare, ignorando l'impostazione predefinita di cercare la directory corrente ei relativi genitori per un file denominato Cargo.toml
(questo file è il "manifest").
Incidentalmente, comandi unix-y solito prendono un argomento -h
o --help
che stampi le informazioni relative opzioni della linea di comando, e cargo
rustc
non fanno eccezione. Per esempio.
$ cargo run --help
Run the main binary of the local package (src/main.rs)
Usage:
cargo run [options] [--] [<args>...]
Options:
-h, --help Print this message
--bin NAME Name of the bin target to run
--example NAME Name of the example target to run
-j N, --jobs N The number of jobs to run in parallel
--release Build artifacts in release mode, with optimizations
--features FEATURES Space-separated list of features to also build
--no-default-features Do not build the `default` feature
--target TRIPLE Build for the target triple
--manifest-path PATH Path to the manifest to execute
-v, --verbose Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
If neither `--bin` nor `--example` are given, then if the project only has one
bin target it will be run. Otherwise `--bin` specifies the bin target to run,
and `--example` specifies the example target to run. At most one of `--bin` or
`--example` can be provided.
All of the trailing arguments are passed to the binary to run. If you're passing
arguments to both Cargo and the binary, the ones after `--` go to the binary,
Forse si desidera l'opzione '--manifest-path'? (L'argomento '--help' stamperà gli argomenti e le descrizioni di essi.) – huon
Voglio essere in grado di compilare ed eseguire un progetto posizionato non nella directory di lavoro corrente, ma nel percorso che io specifichi –
In * nix shell terminology, potresti usare '(cd $ project_path; cargo run)': avvia una nuova sottoshell, in cui cambi la directory e poi esegui il task desiderato. Per Windows penso che sarebbe qualcosa di vagamente sulla falsariga di 'cmd -c" cd% project_path%; cargo run "'. –