gitbook 入門教程之經常使用命令詳解

不管是 gitbook-cli 命令行仍是 gitbook editor 編輯器都離不開 gitbook 命令的操做使用,因此再次瞭解下經常使用命令.git

注意 gitbook-cligitbook 的腳手架工具,是 gitbook 的擴展功能,同時着管理 gitbook.web

查看 gitbook 幫助信息

語法格式: gitbook --help

示例:json

$ gitbook --help

  Usage: gitbook [options] [command]


  Options:

    -v, --gitbook [version]  specify GitBook version to use
    -d, --debug              enable verbose error
    -V, --version            Display running versions of gitbook and gitbook-cli
    -h, --help               output usage information


  Commands:

    ls                        List versions installed locally
    current                   Display currently activated version
    ls-remote                 List remote versions available for install
    fetch [version]           Download and install a <version>
    alias [folder] [version]  Set an alias named <version> pointing to <folder>
    uninstall [version]       Uninstall a version
    update [tag]              Update to the latest version of GitBook
    help                      List commands for GitBook
    *                         run a command with a specific gitbook version
$

gitbook ls 列出本地安裝版本

語法格式: gitbook ls

示例:服務器

# 列出本地已安裝 `gitbook` 版本
$ gitbook ls

gitbook current 列出當前使用版本

語法格式: gitbook current

示例:編輯器

# 列出當前正在使用的 `gitbook` 版本
$ gitbook current

gitbook ls-remote 列出遠程可用版本

語法格式: gitbook ls-remote

示例:工具

# 列出遠程可用的 `gitbook` 版本
$ gitbook ls-remote

gitbook fetch 安裝指定版本

語法格式: gitbook fetch [version]

示例:fetch

# 下載並安裝指定的 `gitbook` 版本
$ gitbook fetch 2.6.9

gitbook alias 指定文件夾別名

語法格式: gitbook alias [folder] [version]

示例:ui

# 下載並安裝指定的 `gitbook` 版本
$ gitbook alias /Users/sunpo/Desktop/book/gitbook/ 1.0.0

gitbook uninstall 卸載指定版本

語法格式: gitbook uninstall [version]

示例:插件

# 卸載指定的 `gitbook` 版本
$ gitbook uninstall 2.6.9

gitbook update 更新指定版本

語法格式: gitbook update [tag]

示例:命令行

# 默認更新到最新的 `gitbook` 版本
$ gitbook update 

# 更新到指定的 `gitbook` 版本
$ gitbook update 2.6.9

列出 gitbook 可用命令

語法格式: gitbook help

示例:

$ gitbook help
    build [book] [output]       build a book
        --log                   Minimum log level to display (Default is info; Values are debug, info, warn, error, disabled)
        --format                Format to build to (Default is website; Values are website, json, ebook)
        --[no-]timing           Print timing debug information (Default is false)

    serve [book] [output]       serve the book as a website for testing
        --port                  Port for server to listen on (Default is 4000)
        --lrport                Port for livereload server to listen on (Default is 35729)
        --[no-]watch            Enable file watcher and live reloading (Default is true)
        --[no-]live             Enable live reloading (Default is true)
        --[no-]open             Enable opening book in browser (Default is false)
        --browser               Specify browser for opening book (Default is )
        --log                   Minimum log level to display (Default is info; Values are debug, info, warn, error, disabled)
        --format                Format to build to (Default is website; Values are website, json, ebook)

    install [book]              install all plugins dependencies
        --log                   Minimum log level to display (Default is info; Values are debug, info, warn, error, disabled)

    parse [book]                parse and print debug information about a book
        --log                   Minimum log level to display (Default is info; Values are debug, info, warn, error, disabled)

    init [book]                 setup and create files for chapters
        --log                   Minimum log level to display (Default is info; Values are debug, info, warn, error, disabled)

    pdf [book] [output]         build a book into an ebook file
        --log                   Minimum log level to display (Default is info; Values are debug, info, warn, error, disabled)

    epub [book] [output]        build a book into an ebook file
        --log                   Minimum log level to display (Default is info; Values are debug, info, warn, error, disabled)

    mobi [book] [output]        build a book into an ebook file
        --log                   Minimum log level to display (Default is info; Values are debug, info, warn, error, disabled)

$

gitbook build 構建電子書

語法格式: gitbook build [book] [output]

示例:

# 默認輸出到 `_book/` 目錄
$ gitbook build 

# 指定輸出目錄 `/Users/sunpo/Desktop/book/`
$ gitbook build ./ /Users/sunpo/Desktop/book/

# 指定輸出格式 `json`
$ gitbook build --format=json

gitbook serve 啓動本地服務器

語法格式: gitbook serve [book] [output]

示例:

# 默認服務端口: `4000`,熱部署端口: `35729`
$ gitbook serve 

# 指定輸出目錄 `/Users/sunpo/Desktop/book/`
$ gitbook serve ./ /Users/sunpo/Desktop/book/

# 指定服務端口: `5000` 和熱部署端口: `45729`
$ gitbook serve --port=5000 --lrport=45729

gitbook install 安裝插件

語法格式: gitbook install [book]

示例:

# 安裝當前項目所需插件
$ gitbook install 

# 安裝指定項目所需插件 `/Users/sunpo/Desktop/gitbook-demo/`
$ gitbook install /Users/sunpo/Desktop/gitbook-demo/

# 安裝當前項目所需插件且指定日誌輸出級別: `debug`
$ gitbook install --log=debug

gitbook parse 解析電子書

語法格式: gitbook parse [book]

示例:

# 解析並輸出當前項目的 `debug` 級別日誌信息
$ gitbook parse 

# 解析並輸出指定項目的 `/Users/sunpo/Desktop/gitbook-demo/` 的 `debug` 級別日誌信息
$ gitbook parse /Users/sunpo/Desktop/gitbook-demo/

# 解析並輸出當前項目的 `info` 級別日誌信息
$ gitbook parse --log=info

gitbook pdf 輸出 PDF 電子書

語法格式: gitbook pdf [book] [output]

示例:

# 默認輸出到當前項目
$ gitbook pdf 

# 指定輸出文件 `/Users/sunpo/Desktop/book.pdf`
$ gitbook pdf ./ /Users/sunpo/Desktop/book.pdf

# 指定輸出日誌級別: `debug`
$ gitbook pdf --log=debug
可能須要安裝 ebook-convert 相關插件,詳情見相關係列教程.

gitbook epub 輸出 epub 電子書

語法格式: gitbook epub [book] [output]

示例:

# 默認輸出到當前項目
$ gitbook epub 

# 指定輸出文件 `/Users/sunpo/Desktop/book.epub`
$ gitbook epub ./ /Users/sunpo/Desktop/book.epub

# 指定輸出日誌級別: `debug`
$ gitbook epub --log=debug
可能須要安裝 ebook-convert 相關插件,詳情見相關係列教程.

gitbook mobi 輸出 mobi 電子書

語法格式: gitbook mobi [book] [output]

示例:

# 默認輸出到當前項目
$ gitbook mobi 

# 指定輸出文件 `/Users/sunpo/Desktop/book.mobi`
$ gitbook mobi ./ /Users/sunpo/Desktop/book.mobi

# 指定輸出日誌級別: `debug`
$ gitbook mobi --log=debug
可能須要安裝 ebook-convert 相關插件,詳情見相關係列教程.
相關文章
相關標籤/搜索