fork/cargo

git clone https://git.julia.blue/fork/cargo

Eric Hussfeat: Stabilize Edition 2024 (#14828)4c39aaff6

0.89.0
5.1 KiB136 linesraw
1CARGO-INIT(1)
2
3NAME
4       cargo-init — Create a new Cargo package in an existing directory
5
6SYNOPSIS
7       cargo init [options] [path]
8
9DESCRIPTION
10       This command will create a new Cargo manifest in the current directory.
11       Give a path as an argument to create in the given directory.
12
13       If there are typically-named Rust source files already in the directory,
14       those will be used. If not, then a sample src/main.rs file will be
15       created, or src/lib.rs if --lib is passed.
16
17       If the directory is not already in a VCS repository, then a new
18       repository is created (see --vcs below).
19
20       See cargo-new(1) for a similar command which will create a new package
21       in a new directory.
22
23OPTIONS
24   Init Options
25       --bin
26           Create a package with a binary target (src/main.rs). This is the
27           default behavior.
28
29       --lib
30           Create a package with a library target (src/lib.rs).
31
32       --edition edition
33           Specify the Rust edition to use. Default is 2024. Possible values:
34           2015, 2018, 2021, 2024
35
36       --name name
37           Set the package name. Defaults to the directory name.
38
39       --vcs vcs
40           Initialize a new VCS repository for the given version control system
41           (git, hg, pijul, or fossil) or do not initialize any version control
42           at all (none). If not specified, defaults to git or the
43           configuration value cargo-new.vcs, or none if already inside a VCS
44           repository.
45
46       --registry registry
47           This sets the publish field in Cargo.toml to the given registry name
48           which will restrict publishing only to that registry.
49
50           Registry names are defined in Cargo config files
51           <https://doc.rust-lang.org/cargo/reference/config.html>. If not
52           specified, the default registry defined by the registry.default
53           config key is used. If the default registry is not set and
54           --registry is not used, the publish field will not be set which
55           means that publishing will not be restricted.
56
57   Display Options
58       -v, --verbose
59           Use verbose output. May be specified twice for “very verbose”
60           output which includes extra output such as dependency warnings and
61           build script output. May also be specified with the term.verbose
62           config value
63           <https://doc.rust-lang.org/cargo/reference/config.html>.
64
65       -q, --quiet
66           Do not print cargo log messages. May also be specified with the
67           term.quiet config value
68           <https://doc.rust-lang.org/cargo/reference/config.html>.
69
70       --color when
71           Control when colored output is used. Valid values:
72
73           o  auto (default): Automatically detect if color support is
74              available on the terminal.
75
76           o  always: Always display colors.
77
78           o  never: Never display colors.
79
80           May also be specified with the term.color config value
81           <https://doc.rust-lang.org/cargo/reference/config.html>.
82
83   Common Options
84       +toolchain
85           If Cargo has been installed with rustup, and the first argument to
86           cargo begins with +, it will be interpreted as a rustup toolchain
87           name (such as +stable or +nightly). See the rustup documentation
88           <https://rust-lang.github.io/rustup/overrides.html> for more
89           information about how toolchain overrides work.
90
91       --config KEY=VALUE or PATH
92           Overrides a Cargo configuration value. The argument should be in
93           TOML syntax of KEY=VALUE, or provided as a path to an extra
94           configuration file. This flag may be specified multiple times. See
95           the command-line overrides section
96           <https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides>
97           for more information.
98
99       -C PATH
100           Changes the current working directory before executing any specified
101           operations. This affects things like where cargo looks by default
102           for the project manifest (Cargo.toml), as well as the directories
103           searched for discovering .cargo/config.toml, for example. This
104           option must appear before the command name, for example cargo -C
105           path/to/my-project build.
106
107           This option is only available on the nightly channel
108           <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
109           requires the -Z unstable-options flag to enable (see #10098
110           <https://github.com/rust-lang/cargo/issues/10098>).
111
112       -h, --help
113           Prints help information.
114
115       -Z flag
116           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
117           details.
118
119ENVIRONMENT
120       See the reference
121       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
122       for details on environment variables that Cargo reads.
123
124EXIT STATUS
125       o  0: Cargo succeeded.
126
127       o  101: Cargo failed to complete.
128
129EXAMPLES
130       1. Create a binary Cargo package in the current directory:
131
132              cargo init
133
134SEE ALSO
135       cargo(1), cargo-new(1)
136