1CARGO-NEW(1)                General Commands Manual               CARGO-NEW(1)
2
3
4

NAME

6       cargo-new - Create a new Cargo package
7

SYNOPSIS

9       cargo new [options] path
10

DESCRIPTION

12       This command will create a new Cargo package in the given directory.
13       This includes a simple template with a Cargo.toml manifest, sample
14       source file, and a VCS ignore file. If the directory is not already in
15       a VCS repository, then a new repository is created (see --vcs below).
16
17       See cargo-init(1) for a similar command which will create a new
18       manifest in an existing directory.
19

OPTIONS

21   New Options
22       --bin
23           Create a package with a binary target (src/main.rs). This is the
24           default behavior.
25
26       --lib
27           Create a package with a library target (src/lib.rs).
28
29       --edition edition
30           Specify the Rust edition to use. Default is 2021. Possible values:
31           2015, 2018, 2021
32
33       --name name
34           Set the package name. Defaults to the directory name.
35
36       --vcs vcs
37           Initialize a new VCS repository for the given version control
38           system (git, hg, pijul, or fossil) or do not initialize any version
39           control at all (none). If not specified, defaults to git or the
40           configuration value cargo-new.vcs, or none if already inside a VCS
41           repository.
42
43       --registry registry
44           This sets the publish field in Cargo.toml to the given registry
45           name which will restrict publishing only to that registry.
46
47           Registry names are defined in Cargo config files
48           <https://doc.rust-lang.org/cargo/reference/config.html>. If not
49           specified, the default registry defined by the registry.default
50           config key is used. If the default registry is not set and
51           --registry is not used, the publish field will not be set which
52           means that publishing will not be restricted.
53
54   Display Options
55       -v, --verbose
56           Use verbose output. May be specified twice for "very verbose"
57           output which includes extra output such as dependency warnings and
58           build script output. May also be specified with the term.verbose
59           config value
60           <https://doc.rust-lang.org/cargo/reference/config.html>.
61
62       -q, --quiet
63           No output printed to stdout.
64
65       --color when
66           Control when colored output is used. Valid values:
67
68auto (default): Automatically detect if color support is
69               available on the terminal.
70
71always: Always display colors.
72
73never: Never display colors.
74
75           May also be specified with the term.color config value
76           <https://doc.rust-lang.org/cargo/reference/config.html>.
77
78   Common Options
79       +toolchain
80           If Cargo has been installed with rustup, and the first argument to
81           cargo begins with +, it will be interpreted as a rustup toolchain
82           name (such as +stable or +nightly). See the rustup documentation
83           <https://rust-lang.github.io/rustup/overrides.html> for more
84           information about how toolchain overrides work.
85
86       -h, --help
87           Prints help information.
88
89       -Z flag
90           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
91           details.
92

ENVIRONMENT

94       See the reference
95       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
96       for details on environment variables that Cargo reads.
97

EXIT STATUS

990: Cargo succeeded.
100
101101: Cargo failed to complete.
102

EXAMPLES

104        1. Create a binary Cargo package in the given directory:
105
106               cargo new foo
107

SEE ALSO

109       cargo(1), cargo-init(1)
110
111
112
113                                                                  CARGO-NEW(1)
Impressum