gitbook 入門教程之常用命令詳解
不論是gitbook-cli
命令列還是gitbook editor
編輯器都離不開gitbook
命令的操作使用,所以再次瞭解下常用命令.
注意gitbook-cli
是gitbook
的腳手架工具,是gitbook
的擴充套件功能,同時著管理gitbook
.
檢視gitbook
幫助資訊
語法格式:gitbook --help
示例:
$ gitbook --help Usage: gitbook [options] [command] Options: -v, --gitbook [version]specify GitBook version to use -d, --debugenable verbose error -V, --versionDisplay running versions of gitbook and gitbook-cli -h, --helpoutput usage information Commands: lsList versions installed locally currentDisplay currently activated version ls-remoteList 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 helpList 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]
示例:
# 下載並安裝指定的 `gitbook` 版本 $ gitbook fetch 2.6.9
gitbook alias
指定資料夾別名
語法格式:gitbook alias [folder] [version]
示例:
# 下載並安裝指定的 `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 --logMinimum log level to display (Default is info; Values are debug, info, warn, error, disabled) --formatFormat to build to (Default is website; Values are website, json, ebook) --[no-]timingPrint timing debug information (Default is false) serve [book] [output]serve the book as a website for testing --portPort for server to listen on (Default is 4000) --lrportPort for livereload server to listen on (Default is 35729) --[no-]watchEnable file watcher and live reloading (Default is true) --[no-]liveEnable live reloading (Default is true) --[no-]openEnable opening book in browser (Default is false) --browserSpecify browser for opening book (Default is ) --logMinimum log level to display (Default is info; Values are debug, info, warn, error, disabled) --formatFormat to build to (Default is website; Values are website, json, ebook) install [book]install all plugins dependencies --logMinimum log level to display (Default is info; Values are debug, info, warn, error, disabled) parse [book]parse and print debug information about a book --logMinimum log level to display (Default is info; Values are debug, info, warn, error, disabled) init [book]setup and create files for chapters --logMinimum log level to display (Default is info; Values are debug, info, warn, error, disabled) pdf [book] [output]build a book into an ebook file --logMinimum log level to display (Default is info; Values are debug, info, warn, error, disabled) epub [book] [output]build a book into an ebook file --logMinimum log level to display (Default is info; Values are debug, info, warn, error, disabled) mobi [book] [output]build a book into an ebook file --logMinimum 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
相關外掛,詳情見相關係列教程.