2015-07-30 17:59:08 +08:00
|
|
|
# Command Line Tool
|
|
|
|
|
2018-08-03 10:19:47 +08:00
|
|
|
mdBook can be used either as a command line tool or a [Rust
|
|
|
|
crate](https://crates.io/crates/mdbook). Let's focus on the command line tool
|
|
|
|
capabilities first.
|
2015-09-25 04:19:14 +08:00
|
|
|
|
2018-08-03 10:19:47 +08:00
|
|
|
## Install From Binaries
|
|
|
|
|
|
|
|
Precompiled binaries are provided for major platforms on a best-effort basis.
|
|
|
|
Visit [the releases page](https://github.com/rust-lang-nursery/mdBook/releases)
|
|
|
|
to download the appropriate version for your platform.
|
|
|
|
|
|
|
|
## Install From Source
|
|
|
|
|
|
|
|
mdBook can also be installed from source
|
2015-09-25 04:19:14 +08:00
|
|
|
|
2015-12-30 22:04:24 +08:00
|
|
|
### Pre-requisite
|
2015-09-25 04:19:14 +08:00
|
|
|
|
2018-08-03 10:19:47 +08:00
|
|
|
mdBook is written in **[Rust](https://www.rust-lang.org/)** and therefore needs
|
|
|
|
to be compiled with **Cargo**. If you haven't already installed Rust, please go
|
2018-12-15 09:09:23 +08:00
|
|
|
ahead and [install it](https://www.rust-lang.org/tools/install) now.
|
2015-09-25 04:19:14 +08:00
|
|
|
|
2015-12-30 22:04:24 +08:00
|
|
|
### Install Crates.io version
|
|
|
|
|
2018-08-03 10:19:47 +08:00
|
|
|
Installing mdBook is relatively easy if you already have Rust and Cargo
|
|
|
|
installed. You just have to type this snippet in your terminal:
|
2015-12-30 22:04:24 +08:00
|
|
|
|
|
|
|
```bash
|
|
|
|
cargo install mdbook
|
|
|
|
```
|
|
|
|
|
2018-08-03 10:19:47 +08:00
|
|
|
This will fetch the source code for the latest release from
|
|
|
|
[Crates.io](https://crates.io/) and compile it. You will have to add Cargo's
|
|
|
|
`bin` directory to your `PATH`.
|
2015-12-30 22:04:24 +08:00
|
|
|
|
2018-08-03 10:19:47 +08:00
|
|
|
Run `mdbook help` in your terminal to verify if it works. Congratulations, you
|
|
|
|
have installed mdBook!
|
2015-12-30 22:04:24 +08:00
|
|
|
|
|
|
|
|
|
|
|
### Install Git version
|
|
|
|
|
2018-08-03 10:19:47 +08:00
|
|
|
The **[git version](https://github.com/rust-lang-nursery/mdBook)** contains all
|
|
|
|
the latest bug-fixes and features, that will be released in the next version on
|
|
|
|
**Crates.io**, if you can't wait until the next release. You can build the git
|
|
|
|
version yourself. Open your terminal and navigate to the directory of you
|
|
|
|
choice. We need to clone the git repository and then build it with Cargo.
|
2015-09-25 04:19:14 +08:00
|
|
|
|
2015-12-30 06:59:08 +08:00
|
|
|
```bash
|
2017-11-22 18:35:18 +08:00
|
|
|
git clone --depth=1 https://github.com/rust-lang-nursery/mdBook.git
|
2015-09-25 04:19:14 +08:00
|
|
|
cd mdBook
|
|
|
|
cargo build --release
|
|
|
|
```
|
|
|
|
|
2018-08-03 10:19:47 +08:00
|
|
|
The executable `mdbook` will be in the `./target/release` folder, this should be
|
|
|
|
added to the path.
|