From 9cb10e68a2f225b5e993043f13da98568a41c50a Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 12 Feb 2018 20:00:59 +0300 Subject: [PATCH] Switch `cargo new` default to `--bin` --- src/bin/init.rs | 4 ++-- src/bin/new.rs | 4 ++-- src/cargo/ops/cargo_new.rs | 4 ++-- src/doc/src/getting-started/first-steps.md | 2 +- src/doc/src/guide/creating-a-new-project.md | 6 ++---- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/bin/init.rs b/src/bin/init.rs index 74ae608acc2..7d2a8593cda 100644 --- a/src/bin/init.rs +++ b/src/bin/init.rs @@ -32,8 +32,8 @@ Options: control system (git, hg, pijul, or fossil) or do not initialize any version control at all (none), overriding a global configuration. - --bin Use a binary (application) template - --lib Use a library template [default] + --bin Use a binary (application) template [default] + --lib Use a library template --name NAME Set the resulting package name -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet No output printed to stdout diff --git a/src/bin/new.rs b/src/bin/new.rs index 6b51a6180bd..e18dcf8c27b 100644 --- a/src/bin/new.rs +++ b/src/bin/new.rs @@ -32,8 +32,8 @@ Options: control system (git, hg, pijul, or fossil) or do not initialize any version control at all (none), overriding a global configuration. - --bin Use a binary (application) template - --lib Use a library template [default] + --bin Use a binary (application) template [default] + --lib Use a library template --name NAME Set the resulting package name, defaults to the value of -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet No output printed to stdout diff --git a/src/cargo/ops/cargo_new.rs b/src/cargo/ops/cargo_new.rs index 3cba288be93..aaaa69e2176 100644 --- a/src/cargo/ops/cargo_new.rs +++ b/src/cargo/ops/cargo_new.rs @@ -92,8 +92,8 @@ impl<'a> NewOptions<'a> { (true, true) => bail!("can't specify both lib and binary outputs"), (true, false) => NewProjectKind::Bin, (false, true) => NewProjectKind::Lib, - // default to lib - (false, false) => NewProjectKind::Lib, + // default to bin + (false, false) => NewProjectKind::Bin, }; let opts = NewOptions { version_control, kind, path, name }; diff --git a/src/doc/src/getting-started/first-steps.md b/src/doc/src/getting-started/first-steps.md index 6b31d8d0c86..3a0bad35651 100644 --- a/src/doc/src/getting-started/first-steps.md +++ b/src/doc/src/getting-started/first-steps.md @@ -7,7 +7,7 @@ $ cargo new hello_world --bin ``` We’re passing `--bin` because we’re making a binary program: if we -were making a library, we’d leave it off. +were making a library, we’d pass `--lib`. Let’s check out what Cargo has generated for us: diff --git a/src/doc/src/guide/creating-a-new-project.md b/src/doc/src/guide/creating-a-new-project.md index 3566e02a337..98f2a65d754 100644 --- a/src/doc/src/guide/creating-a-new-project.md +++ b/src/doc/src/guide/creating-a-new-project.md @@ -7,7 +7,7 @@ $ cargo new hello_world --bin ``` We’re passing `--bin` because we’re making a binary program: if we -were making a library, we’d leave it off. This also initializes a new `git` +were making a library, we’d pass `--lib`. This also initializes a new `git` repository by default. If you don't want it to do that, pass `--vcs none`. Let’s check out what Cargo has generated for us: @@ -23,9 +23,7 @@ $ tree . 1 directory, 2 files ``` -If we had just used `cargo new hello_world` without the `--bin` flag, then -we would have a `lib.rs` instead of a `main.rs`. For now, however, this is all -we need to get started. First, let’s check out `Cargo.toml`: +Let’s take a closer look at `Cargo.toml`: ```toml [package]