Skip to content
This repository has been archived by the owner on Jan 15, 2025. It is now read-only.

Commit

Permalink
Remove debug option
Browse files Browse the repository at this point in the history
  • Loading branch information
babarot committed Mar 2, 2017
1 parent 7304e38 commit cba34f9
Showing 4 changed files with 16 additions and 11 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -14,8 +14,6 @@ Usage of ./qiita2crowi:
Crowi's access token
-crowi-url string
Your Crowi base URL
-debug
Logging verbosely
-page-path string
Default page path (default "/qiita")
```
2 changes: 0 additions & 2 deletions docs/README_ja.md
Original file line number Diff line number Diff line change
@@ -14,8 +14,6 @@ Usage of ./qiita2crowi:
Crowi's access token
-crowi-url string
Your Crowi base URL
-debug
Logging verbosely
-page-path string
Default page path (default "/qiita")
```
11 changes: 9 additions & 2 deletions docs/spec_ja.md
Original file line number Diff line number Diff line change
@@ -6,11 +6,14 @@ Spec
- このツールを使うにあたり、Qiita:Team にある記事を Dumping した JSON ファイルが必要です
- Qiita:Team では記事のエクスポート機能があるのでそれを使ってください
- その JSON ファイルを標準出力から食わせると、パースしてよしなに Crowi API に投げてくれます
- 実行すると、
- 実行すると、
- まずは記事を作成します
- そのとき JSON にある title 要素が Crowi の記事のパスとして使われます
- `qiita2crowi``-page-path` オプションを使えばその記事の root path を設定できます (default: `/qiita`)
- title にある `^`, `$`, `*`, `%`, `?`, `/` は全角に置換されます
- title にある以下の文字は全角に置換されます
- `^`, `$`, `*`: Crowi 内で正規表現として使用される
- `%`, `?`: クエリ
- `/`: ページパス (予期しない階層化を防ぐため)
- Qiita 記事についているコメントは本文末尾に追記される形になります
- 次に、画像をアップロードします
- Qiita からアップロードされた画像ファイルは `qiita-image-store.s3.amazonaws.com` というホスト名の URL を持ちます
@@ -22,6 +25,10 @@ Spec
- 4 つの goroutine を起動して並列に処理します
- 最適化用のオプションなどは提供していません

### 未実装

- ページ内リンク (Qiita:Team 参照のもの) の書き換え

## 参考

- [Qiita::Team やめた - @kyanny's blog](http://blog.kyanny.me/entry/2015/07/30/020046)
12 changes: 7 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ import (
"encoding/json"
"flag"
"fmt"
"log"
"os"
"regexp"
"strings"
@@ -16,7 +17,6 @@ var (
)

var (
debug = flag.Bool("debug", false, "Logging verbosely")
accessToken = flag.String("access-token", "", "Crowi's access token")
crowiUrl = flag.String("crowi-url", "", "Your Crowi base URL")
pagePath = flag.String("page-path", "/qiita", "Default page path")
@@ -25,26 +25,28 @@ var (
func main() {
flag.Parse()

dec := json.NewDecoder(os.Stdin)
var q Qiita
dec := json.NewDecoder(os.Stdin)
dec.Decode(&q)

wg := sync.WaitGroup{}
hasError := false
errs := 0

for _, article := range q.Articles {
wg.Add(1)
go func(a Articles) {
err := qiita2crowi(a)
if err != nil {
hasError = true
log.Printf("[ERROR] %s", err.Error())
errs++
}
wg.Done()
}(article)
}
wg.Wait()

if hasError {
if errs > 0 {
log.Printf("Failures %d/%d pages", errs, len(q.Articles))
os.Exit(1)
}
}

0 comments on commit cba34f9

Please sign in to comment.