Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
shihyuho committed Jun 22, 2021
1 parent a92ab8b commit ac8dc54
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions toc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,27 @@ import (
)

const (
desc = `Table Of Content Generator
$ toc PATH
PATH 用來指定從哪層目錄 (相對於工作目錄) 開始爬文, 如: '.' 代表當前目錄
$ toc .
傳入 '--workdir' 指定工作目錄, 可為絕對路徑或相對於當前目錄的路徑, 預設執行指令的當前目錄
$ toc . --workdir ../../
$ toc . --workdir /tmp
傳入 '--template' 指定 template 位置 (相對於工作目錄)
$ toc . --template templates/my.tpl
傳入 '--output' 指令輸出的檔案 (相對於工作目錄)
$ toc . --template templates/my.tpl --output my.file
`
coursesTemplate = `> Auto-generated by *toc*
{{- $years := index . "years" }}
{{- $courses := index . "courses" }}
Expand Down Expand Up @@ -44,28 +65,8 @@ func main() {
cmd := &cobra.Command{
Use: "toc",
Short: "Table Of Content generator",
Long: `Table Of Content Generator
$ toc PATH
PATH 用來指定從哪層目錄 (相對於工作目錄) 開始爬文, 如: '.' 代表當前目錄
$ toc .
傳入 '--workdir' 指定工作目錄, 可為絕對路徑或相對於當前目錄的路徑, 預設執行指令的當前目錄
$ toc . --workdir ../../
$ toc . --workdir /tmp
傳入 '--template' 指定 template 位置 (相對於工作目錄)
$ toc . --template templates/my.tpl
傳入 '--output' 指令輸出的檔案 (相對於工作目錄)
$ toc . --template templates/my.tpl --output my.file
`,
Args: cobra.ExactArgs(1),
Long: desc,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
c.scandir = args[0]
return generateTOC(c)
Expand Down

0 comments on commit ac8dc54

Please sign in to comment.