Skip to content

a simple toolbox bash script for main repositry Textbook.

License

Notifications You must be signed in to change notification settings

techno-tutors/tb2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tb2

A simple toolbox bash script for main repositry Textbook. This contains GitHub automations, auto commit or auto issue for example. This has 2 mode, Interactive and basic commands. (TextBook ToolBox === TB2)

About

How to Install

3 opts, all one-line so you can now copy-and-paste to run.

use GIT

git clone https://github.com/techno-tutors/tb2.git;
cd tb2;
sh ./install.sh;

use CURL

curl -fsSL https://raw.githubusercontent.com/techno-tutors/tb2/refs/heads/main/install.sh | sh

use WGET

wget -qO- https://raw.githubusercontent.com/techno-tutors/tb2/refs/heads/main/install.sh | sh

Usage

<GitHubの動き>にはGitのみの動作も含まれます。


subcmd "book"

tb2 book new -b BOOKNAME
#または
tb2 book new BOOKNAME

新しい本NAMEを作成します。

GitHubの動き

  • GitHub ProjectへBOOKNAMEが追加されます。

tb2 book list

本一覧を表示します。


subcmd "chapter"

tb2 chapter new -c CHAPTERNAME -b BOOKNAME
#または
tb2 chapter new BOOKNAME/CHAPTERNAME

新しいチャプターNAMEを本BOOKNAMEに作成します。

GitHubの動き

  • チャプター用のブランチがdraftから切られます。
  • チャプター用のissueがProject(BOOKNAME)に立てられます。

tb2 chapter save -c CHAPTERNAME -b BOOKNAME
#または
tb2 chapter save BOOKNAME/CHAPTERNAME

チャプターを保存します。

GitHubの動き

  • チャプター用のブランチをdraftブランチにプルリクエストします。

tb2 chapter list -b BOOKNAME
#または
tb2 chapter list BOOKNAME

本BOOKNAMEのチャプター一覧を表示します。


subcmd "page"

tb2 page new -c CHAPTERNAME -b BOOKNAME [-p PAGENAME]
#または
tb2 page new BOOKNAME/CHAPTERNAME/PAGENAME

テンプレートからMDを作成します。
-pを指定しなかった場合、ページの名前は連番でpageNとなります。

GitHubの動き

  • SubIssueが立てられます。

tb2 page save -c CHAPTERNAME -b BOOKNAME -p PAGENAME
#または
tb2 page save CHAPTERNAME/BOOKNAME/PAGENAME

ページを保存します。

GitHubの動き

  • コミット、及びその一連の流れをします。

subcmd "project"

tb2 project list

プロジェクト全体の本とチャプターを表示します。


tb2 project list -p|-page

プロジェクト全体の本,チャプター,及びそれに含まれるページも表示します。


Interactive Mode

tb2 [-i]

Example

TB2を使うと、教科書制作のGitHub作業やディレクトリいじり、テンプレの適用などが自動化されます。 以下は、ツール直打ち(対話モードではない)で、本→チャプター→ページを作る一連の例です。

1. 本を作る

tb2 book new Crypto
  • GitHub ProjectにCryptoが追加されます -bで明示的にBOOKNAMEを指定してもいいけど略しても変わらん。

2. チャプターを作る

tb2 chapter new Crypto/RSA
#もしくは
tb2 chapter new -b Crypto -c RSA
  • draftブランチからchapter/RSAブランチが作成されます
  • "RSA"のIssueがProject(Crypto)に作成されます

3. ページを書く

tb2 page new Crypto/RSA/WhatIsRSA

ここで-c,-b,-pでわざわざ指定するのはめんどい。短縮形を使おう。

  • Sub-Issue が作成されます
  • WhatIsRSA.mdが作成されます

4. 編集

5. ページを保存する

tb2 page save Crypto/RSA/WhatIsRSA
  • 変更がcommit&pushされます

6. チャプターを完成させる

tb2 chapter save Crypto/RSA
  • chapter/RSAブランチからdraftブランチにPRがつくられます。
  • RSA chapterのissueはDONEやclosedにはなりません

7. 満足する

tb2 project list -page
  • 本 → チャプター → ページ の階層が一覧表示されます 自分が成し遂げた成果を見渡そう。

LICENSE

ISC License. It is almost the same as MIT License.

Contribute

  • Branch: Only "main"
  • Commit Msg Pattern: Short English
  • Code Lang: Bash
  • Code style: Mustn't use external command usually.
  • Dir:
    • /install.sh[bash]
    • /script/tb2[bash]
    • /script/subcmds/subcmdname.d[dir]
    • /script/subcmds/subcmdname.d/cmdname[bash]
    • /script/subcmds/subcmdname.d/subcmds/subsubcmdname[bash]
  • Indent: 2 spaces or tab
  • You havta do shfmt
  • You havta add set -euo pipfail to head of bash file
  • Shebang is allowd only #!/us/bin/env bash
  • tag v* commit to Release

About

a simple toolbox bash script for main repositry Textbook.

Topics

Resources

License

Stars

Watchers

Forks

Languages