Matthew Maurer | bd39854 | 2019-09-05 16:25:08 -0700 | [diff] [blame] | 1 | '\" t |
| 2 | .\" Title: cargo-run |
| 3 | .\" Author: [see the "AUTHOR(S)" section] |
| 4 | .\" Generator: Asciidoctor 1.5.8 |
| 5 | .\" Date: 2019-05-08 |
| 6 | .\" Manual: \ \& |
| 7 | .\" Source: \ \& |
| 8 | .\" Language: English |
| 9 | .\" |
| 10 | .TH "CARGO\-RUN" "1" "2019-05-08" "\ \&" "\ \&" |
| 11 | .ie \n(.g .ds Aq \(aq |
| 12 | .el .ds Aq ' |
| 13 | .ss \n[.ss] 0 |
| 14 | .nh |
| 15 | .ad l |
| 16 | .de URL |
| 17 | \fI\\$2\fP <\\$1>\\$3 |
| 18 | .. |
| 19 | .als MTO URL |
| 20 | .if \n[.g] \{\ |
| 21 | . mso www.tmac |
| 22 | . am URL |
| 23 | . ad l |
| 24 | . . |
| 25 | . am MTO |
| 26 | . ad l |
| 27 | . . |
| 28 | . LINKSTYLE blue R < > |
| 29 | .\} |
| 30 | .SH "NAME" |
| 31 | cargo\-run \- Run the current package |
| 32 | .SH "SYNOPSIS" |
| 33 | .sp |
| 34 | \fBcargo run [\fIOPTIONS\fP] [\-\- \fIARGS\fP]\fP |
| 35 | .SH "DESCRIPTION" |
| 36 | .sp |
| 37 | Run a binary or example of the local package. |
| 38 | .sp |
| 39 | All the arguments following the two dashes (\fB\-\-\fP) are passed to the binary to |
| 40 | run. If you\(cqre passing arguments to both Cargo and the binary, the ones after |
| 41 | \fB\-\-\fP go to the binary, the ones before go to Cargo. |
| 42 | .SH "OPTIONS" |
| 43 | .SS "Package Selection" |
| 44 | .sp |
| 45 | By default, the package in the current working directory is selected. The \fB\-p\fP |
| 46 | flag can be used to choose a different package in a workspace. |
| 47 | .sp |
| 48 | \fB\-p\fP \fISPEC\fP, \fB\-\-package\fP \fISPEC\fP |
| 49 | .RS 4 |
| 50 | The package to run. See \fBcargo\-pkgid\fP(1) for |
| 51 | the SPEC format. |
| 52 | .RE |
| 53 | .SS "Target Selection" |
| 54 | .sp |
| 55 | When no target selection options are given, \fBcargo run\fP will run the binary |
| 56 | target. If there are multiple binary targets, you must pass a target flag to |
| 57 | choose one. |
| 58 | .sp |
| 59 | \fB\-\-bin\fP \fINAME\fP |
| 60 | .RS 4 |
| 61 | Run the specified binary. |
| 62 | .RE |
| 63 | .sp |
| 64 | \fB\-\-example\fP \fINAME\fP |
| 65 | .RS 4 |
| 66 | Run the specified example. |
| 67 | .RE |
| 68 | .SS "Feature Selection" |
| 69 | .sp |
| 70 | When no feature options are given, the \fBdefault\fP feature is activated for |
| 71 | every selected package. |
| 72 | .sp |
| 73 | \fB\-\-features\fP \fIFEATURES\fP |
| 74 | .RS 4 |
| 75 | Space or comma separated list of features to activate. These features only |
| 76 | apply to the current directory\(cqs package. Features of direct dependencies |
| 77 | may be enabled with \fB<dep\-name>/<feature\-name>\fP syntax. |
| 78 | .RE |
| 79 | .sp |
| 80 | \fB\-\-all\-features\fP |
| 81 | .RS 4 |
| 82 | Activate all available features of all selected packages. |
| 83 | .RE |
| 84 | .sp |
| 85 | \fB\-\-no\-default\-features\fP |
| 86 | .RS 4 |
| 87 | Do not activate the \fBdefault\fP feature of the current directory\(cqs |
| 88 | package. |
| 89 | .RE |
| 90 | .SS "Compilation Options" |
| 91 | .sp |
| 92 | \fB\-\-target\fP \fITRIPLE\fP |
| 93 | .RS 4 |
| 94 | Run for the given architecture. The default is the host |
| 95 | architecture. The general format of the triple is |
| 96 | \fB<arch><sub>\-<vendor>\-<sys>\-<abi>\fP. Run \fBrustc \-\-print target\-list\fP for a |
| 97 | list of supported targets. |
| 98 | .sp |
| 99 | This may also be specified with the \fBbuild.target\fP |
| 100 | .URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." |
| 101 | .RE |
| 102 | .sp |
| 103 | \fB\-\-release\fP |
| 104 | .RS 4 |
| 105 | Run optimized artifacts with the \fBrelease\fP profile. See the |
| 106 | PROFILES section for details on how this affects profile selection. |
| 107 | .RE |
| 108 | .SS "Output Options" |
| 109 | .sp |
| 110 | \fB\-\-target\-dir\fP \fIDIRECTORY\fP |
| 111 | .RS 4 |
| 112 | Directory for all generated artifacts and intermediate files. May also be |
| 113 | specified with the \fBCARGO_TARGET_DIR\fP environment variable, or the |
| 114 | \fBbuild.target\-dir\fP \c |
| 115 | .URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." |
| 116 | Defaults |
| 117 | to \fBtarget\fP in the root of the workspace. |
| 118 | .RE |
| 119 | .SS "Display Options" |
| 120 | .sp |
| 121 | \fB\-v\fP, \fB\-\-verbose\fP |
| 122 | .RS 4 |
| 123 | Use verbose output. May be specified twice for "very verbose" output which |
| 124 | includes extra output such as dependency warnings and build script output. |
| 125 | May also be specified with the \fBterm.verbose\fP |
| 126 | .URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." |
| 127 | .RE |
| 128 | .sp |
| 129 | \fB\-q\fP, \fB\-\-quiet\fP |
| 130 | .RS 4 |
| 131 | No output printed to stdout. |
| 132 | .RE |
| 133 | .sp |
| 134 | \fB\-\-color\fP \fIWHEN\fP |
| 135 | .RS 4 |
| 136 | Control when colored output is used. Valid values: |
| 137 | .sp |
| 138 | .RS 4 |
| 139 | .ie n \{\ |
| 140 | \h'-04'\(bu\h'+03'\c |
| 141 | .\} |
| 142 | .el \{\ |
| 143 | . sp -1 |
| 144 | . IP \(bu 2.3 |
| 145 | .\} |
| 146 | \fBauto\fP (default): Automatically detect if color support is available on the |
| 147 | terminal. |
| 148 | .RE |
| 149 | .sp |
| 150 | .RS 4 |
| 151 | .ie n \{\ |
| 152 | \h'-04'\(bu\h'+03'\c |
| 153 | .\} |
| 154 | .el \{\ |
| 155 | . sp -1 |
| 156 | . IP \(bu 2.3 |
| 157 | .\} |
| 158 | \fBalways\fP: Always display colors. |
| 159 | .RE |
| 160 | .sp |
| 161 | .RS 4 |
| 162 | .ie n \{\ |
| 163 | \h'-04'\(bu\h'+03'\c |
| 164 | .\} |
| 165 | .el \{\ |
| 166 | . sp -1 |
| 167 | . IP \(bu 2.3 |
| 168 | .\} |
| 169 | \fBnever\fP: Never display colors. |
| 170 | .RE |
| 171 | .sp |
| 172 | May also be specified with the \fBterm.color\fP |
| 173 | .URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." |
| 174 | .RE |
| 175 | .sp |
| 176 | \fB\-\-message\-format\fP \fIFMT\fP |
| 177 | .RS 4 |
| 178 | The output format for diagnostic messages. Valid values: |
| 179 | .sp |
| 180 | .RS 4 |
| 181 | .ie n \{\ |
| 182 | \h'-04'\(bu\h'+03'\c |
| 183 | .\} |
| 184 | .el \{\ |
| 185 | . sp -1 |
| 186 | . IP \(bu 2.3 |
| 187 | .\} |
| 188 | \fBhuman\fP (default): Display in a human\-readable text format. |
| 189 | .RE |
| 190 | .sp |
| 191 | .RS 4 |
| 192 | .ie n \{\ |
| 193 | \h'-04'\(bu\h'+03'\c |
| 194 | .\} |
| 195 | .el \{\ |
| 196 | . sp -1 |
| 197 | . IP \(bu 2.3 |
| 198 | .\} |
| 199 | \fBjson\fP: Emit JSON messages to stdout. |
| 200 | .RE |
| 201 | .sp |
| 202 | .RS 4 |
| 203 | .ie n \{\ |
| 204 | \h'-04'\(bu\h'+03'\c |
| 205 | .\} |
| 206 | .el \{\ |
| 207 | . sp -1 |
| 208 | . IP \(bu 2.3 |
| 209 | .\} |
| 210 | \fBshort\fP: Emit shorter, human\-readable text messages. |
| 211 | .RE |
| 212 | .RE |
| 213 | .SS "Manifest Options" |
| 214 | .sp |
| 215 | \fB\-\-manifest\-path\fP \fIPATH\fP |
| 216 | .RS 4 |
| 217 | Path to the \fBCargo.toml\fP file. By default, Cargo searches in the current |
| 218 | directory or any parent directory for the \fBCargo.toml\fP file. |
| 219 | .RE |
| 220 | .sp |
| 221 | \fB\-\-frozen\fP, \fB\-\-locked\fP |
| 222 | .RS 4 |
| 223 | Either of these flags requires that the \fBCargo.lock\fP file is |
| 224 | up\-to\-date. If the lock file is missing, or it needs to be updated, Cargo will |
| 225 | exit with an error. The \fB\-\-frozen\fP flag also prevents Cargo from |
| 226 | attempting to access the network to determine if it is out\-of\-date. |
| 227 | .sp |
| 228 | These may be used in environments where you want to assert that the |
| 229 | \fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network |
| 230 | access. |
| 231 | .RE |
| 232 | .sp |
| 233 | \fB\-\-offline\fP |
| 234 | .RS 4 |
| 235 | Prevents Cargo from accessing the network for any reason. Without this |
| 236 | flag, Cargo will stop with an error if it needs to access the network and |
| 237 | the network is not available. With this flag, Cargo will attempt to |
| 238 | proceed without the network if possible. |
| 239 | .sp |
| 240 | Beware that this may result in different dependency resolution than online |
| 241 | mode. Cargo will restrict itself to crates that are downloaded locally, even |
| 242 | if there might be a newer version as indicated in the local copy of the index. |
| 243 | See the \fBcargo\-fetch\fP(1) command to download dependencies before going |
| 244 | offline. |
| 245 | .sp |
| 246 | May also be specified with the \fBnet.offline\fP \c |
| 247 | .URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." |
| 248 | .RE |
| 249 | .SS "Common Options" |
| 250 | .sp |
| 251 | \fB\-h\fP, \fB\-\-help\fP |
| 252 | .RS 4 |
| 253 | Prints help information. |
| 254 | .RE |
| 255 | .sp |
| 256 | \fB\-Z\fP \fIFLAG\fP... |
| 257 | .RS 4 |
| 258 | Unstable (nightly\-only) flags to Cargo. Run \fBcargo \-Z help\fP for |
| 259 | details. |
| 260 | .RE |
| 261 | .SS "Miscellaneous Options" |
| 262 | .sp |
| 263 | \fB\-j\fP \fIN\fP, \fB\-\-jobs\fP \fIN\fP |
| 264 | .RS 4 |
| 265 | Number of parallel jobs to run. May also be specified with the |
| 266 | \fBbuild.jobs\fP \c |
| 267 | .URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." |
| 268 | Defaults to |
| 269 | the number of CPUs. |
| 270 | .RE |
| 271 | .SH "PROFILES" |
| 272 | .sp |
| 273 | Profiles may be used to configure compiler options such as optimization levels |
| 274 | and debug settings. See |
| 275 | \c |
| 276 | .URL "https://doc.rust\-lang.org/cargo/reference/manifest.html#the\-profile\-sections" "the reference" |
| 277 | for more details. |
| 278 | .sp |
| 279 | Profile selection depends on the target and crate being built. By default the |
| 280 | \fBdev\fP or \fBtest\fP profiles are used. If the \fB\-\-release\fP flag is given, then the |
| 281 | \fBrelease\fP or \fBbench\fP profiles are used. |
| 282 | .TS |
| 283 | allbox tab(:); |
| 284 | lt lt lt. |
| 285 | T{ |
| 286 | .sp |
| 287 | Target |
| 288 | T}:T{ |
| 289 | .sp |
| 290 | Default Profile |
| 291 | T}:T{ |
| 292 | .sp |
| 293 | \fB\-\-release\fP Profile |
| 294 | T} |
| 295 | T{ |
| 296 | .sp |
| 297 | lib, bin, example |
| 298 | T}:T{ |
| 299 | .sp |
| 300 | \fBdev\fP |
| 301 | T}:T{ |
| 302 | .sp |
| 303 | \fBrelease\fP |
| 304 | T} |
| 305 | T{ |
| 306 | .sp |
| 307 | test, bench, or any target |
| 308 | .br |
| 309 | in "test" or "bench" mode |
| 310 | T}:T{ |
| 311 | .sp |
| 312 | \fBtest\fP |
| 313 | T}:T{ |
| 314 | .sp |
| 315 | \fBbench\fP |
| 316 | T} |
| 317 | .TE |
| 318 | .sp |
| 319 | .sp |
| 320 | Dependencies use the \fBdev\fP/\fBrelease\fP profiles. |
| 321 | .SH "ENVIRONMENT" |
| 322 | .sp |
| 323 | See \c |
| 324 | .URL "https://doc.rust\-lang.org/cargo/reference/environment\-variables.html" "the reference" " " |
| 325 | for |
| 326 | details on environment variables that Cargo reads. |
| 327 | .SH "EXIT STATUS" |
| 328 | .sp |
| 329 | 0 |
| 330 | .RS 4 |
| 331 | Cargo succeeded. |
| 332 | .RE |
| 333 | .sp |
| 334 | 101 |
| 335 | .RS 4 |
| 336 | Cargo failed to complete. |
| 337 | .RE |
| 338 | .SH "EXAMPLES" |
| 339 | .sp |
| 340 | .RS 4 |
| 341 | .ie n \{\ |
| 342 | \h'-04' 1.\h'+01'\c |
| 343 | .\} |
| 344 | .el \{\ |
| 345 | . sp -1 |
| 346 | . IP " 1." 4.2 |
| 347 | .\} |
| 348 | Build the local package and run its main target (assuming only one binary): |
| 349 | .sp |
| 350 | .if n .RS 4 |
| 351 | .nf |
| 352 | cargo run |
| 353 | .fi |
| 354 | .if n .RE |
| 355 | .RE |
| 356 | .sp |
| 357 | .RS 4 |
| 358 | .ie n \{\ |
| 359 | \h'-04' 2.\h'+01'\c |
| 360 | .\} |
| 361 | .el \{\ |
| 362 | . sp -1 |
| 363 | . IP " 2." 4.2 |
| 364 | .\} |
| 365 | Run an example with extra arguments: |
| 366 | .sp |
| 367 | .if n .RS 4 |
| 368 | .nf |
| 369 | cargo run \-\-example exname \-\- \-\-exoption exarg1 exarg2 |
| 370 | .fi |
| 371 | .if n .RE |
| 372 | .RE |
| 373 | .SH "SEE ALSO" |
| 374 | .sp |
| 375 | \fBcargo\fP(1), \fBcargo\-build\fP(1) |