Skip to content

Commit

Permalink
update toc readme
Browse files Browse the repository at this point in the history
  • Loading branch information
shihyuho committed Jun 19, 2021
1 parent 733ce0a commit b9a9e9d
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
30 changes: 28 additions & 2 deletions toc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,33 @@

Table Of Content 產生器

## Developer

### Environment Requirements

- Golang 1.12+

### Build

輸入 `make help` 可以查看打包指令:

```
Usage:
make <target>
General
help Display this help.
build-all Build compiles the packages for linux, macos and windows
build-linux Build compiles the packages for linux
build-macos Build compiles the packages for macos
build-windows Build compiles the packages for windows
bootstrap Bootstrap project
```

## Usage

輸入 `toc --help` 可以查看完整說明:

```
Table Of Content Generator
Expand All @@ -13,9 +38,10 @@ PATH 用來指定從哪層目錄 (相對於工作目錄) 開始爬文, 如: '.'
$ toc .
傳入 '--workdir' 指定工作目錄, 預設執行指令的當前目錄, 如: 從上一層爬文
傳入 '--workdir' 指定工作目錄, 可為絕對路徑或相對於當前目錄的路徑, 預設執行指令的當前目錄
$ toc . --workdir ../
$ toc . --workdir ../../
$ toc . --workdir /tmp
傳入 '--template' 指定 template 位置 (相對於工作目錄)
Expand Down
14 changes: 8 additions & 6 deletions toc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ PATH 用來指定從哪層目錄 (相對於工作目錄) 開始爬文, 如: '.'
$ toc .
傳入 '--workdir' 指定工作目錄, 預設執行指令的當前目錄, 如: 從上一層爬文
傳入 '--workdir' 指定工作目錄, 可為絕對路徑或相對於當前目錄的路徑, 預設執行指令的當前目錄
$ toc . --workdir ../
$ toc . --workdir ../../
$ toc . --workdir /tmp
傳入 '--template' 指定 template 位置 (相對於工作目錄)
Expand Down Expand Up @@ -84,11 +85,12 @@ PATH 用來指定從哪層目錄 (相對於工作目錄) 開始爬文, 如: '.'
}

func generateTOC(c *config) (err error) {
if c.workdir == "" {
if c.workdir, err = os.Getwd(); err != nil {
return err
}
if c.workdir, err = filepath.Abs(c.workdir); err != nil {
return err
}
fmt.Println(c.workdir)

return

// 爬子目錄收集所有課程目錄
var courses []Course
Expand Down
Binary file modified toc/toc-linux
Binary file not shown.
Binary file modified toc/toc-macos
Binary file not shown.
Binary file modified toc/toc-windows.exe
Binary file not shown.

0 comments on commit b9a9e9d

Please sign in to comment.