AtCoderStudyBooster 0.3__tar.gz → 0.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- atcoderstudybooster-0.3.2/.github/workflows/deploy.yaml +33 -0
- atcoderstudybooster-0.3.2/.images/demo1.png +0 -0
- atcoderstudybooster-0.3.2/.images/demo2.png +0 -0
- atcoderstudybooster-0.3.2/.images/demo3.png +0 -0
- atcoderstudybooster-0.3.2/.images/demo4.png +0 -0
- atcoderstudybooster-0.3.2/PKG-INFO +213 -0
- atcoderstudybooster-0.3.2/README.md +192 -0
- atcoderstudybooster-0.3.2/atcdr/cli.py +86 -0
- atcoderstudybooster-0.3.2/atcdr/download.py +322 -0
- atcoderstudybooster-0.3.2/atcdr/generate.py +202 -0
- atcoderstudybooster-0.3.2/atcdr/login.py +136 -0
- atcoderstudybooster-0.3.2/atcdr/logout.py +27 -0
- atcoderstudybooster-0.3.2/atcdr/markdown.py +43 -0
- atcoderstudybooster-0.3.2/atcdr/open.py +48 -0
- atcoderstudybooster-0.3.2/atcdr/submit.py +302 -0
- atcoderstudybooster-0.3.2/atcdr/test.py +433 -0
- atcoderstudybooster-0.3.2/atcdr/util/fileops.py +102 -0
- atcoderstudybooster-0.3.2/atcdr/util/filetype.py +105 -0
- atcoderstudybooster-0.3.2/atcdr/util/gpt.py +118 -0
- atcoderstudybooster-0.3.2/atcdr/util/parse.py +206 -0
- atcoderstudybooster-0.3.2/atcdr/util/problem.py +94 -0
- atcoderstudybooster-0.3.2/atcdr/util/session.py +140 -0
- {atcoderstudybooster-0.3 → atcoderstudybooster-0.3.2}/pyproject.toml +7 -6
- {atcoderstudybooster-0.3 → atcoderstudybooster-0.3.2}/requirements-dev.lock +16 -36
- {atcoderstudybooster-0.3 → atcoderstudybooster-0.3.2}/requirements.lock +16 -36
- atcoderstudybooster-0.3/.github/workflows/deploy.yaml +0 -40
- atcoderstudybooster-0.3/.images/demo1.png +0 -0
- atcoderstudybooster-0.3/PKG-INFO +0 -96
- atcoderstudybooster-0.3/README.md +0 -76
- atcoderstudybooster-0.3/atcdr/download.py +0 -289
- atcoderstudybooster-0.3/atcdr/generate.py +0 -220
- atcoderstudybooster-0.3/atcdr/main.py +0 -40
- atcoderstudybooster-0.3/atcdr/markdown.py +0 -39
- atcoderstudybooster-0.3/atcdr/open.py +0 -43
- atcoderstudybooster-0.3/atcdr/test.py +0 -438
- atcoderstudybooster-0.3/atcdr/util/cost.py +0 -120
- atcoderstudybooster-0.3/atcdr/util/execute.py +0 -63
- atcoderstudybooster-0.3/atcdr/util/filetype.py +0 -105
- atcoderstudybooster-0.3/atcdr/util/gpt.py +0 -112
- atcoderstudybooster-0.3/atcdr/util/problem.py +0 -91
- {atcoderstudybooster-0.3 → atcoderstudybooster-0.3.2}/.gitignore +0 -0
- {atcoderstudybooster-0.3 → atcoderstudybooster-0.3.2}/.pre-commit-config.yaml +0 -0
- {atcoderstudybooster-0.3 → atcoderstudybooster-0.3.2}/.python-version +0 -0
- {atcoderstudybooster-0.3 → atcoderstudybooster-0.3.2}/.vscode/extensions.json +0 -0
- {atcoderstudybooster-0.3 → atcoderstudybooster-0.3.2}/.vscode/setting.json +0 -0
- {atcoderstudybooster-0.3 → atcoderstudybooster-0.3.2}/.vscode/tasks.json +0 -0
- {atcoderstudybooster-0.3 → atcoderstudybooster-0.3.2}/atcdr/__init__.py +0 -0
- {atcoderstudybooster-0.3 → atcoderstudybooster-0.3.2}/atcdr/util/__init__.py +0 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
name: Deploy to PyPI
|
2
|
+
|
3
|
+
on:
|
4
|
+
release:
|
5
|
+
types: [published]
|
6
|
+
|
7
|
+
permissions:
|
8
|
+
contents: read
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
deploy:
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
|
14
|
+
steps:
|
15
|
+
- name: Checkout repository
|
16
|
+
uses: actions/checkout@v4
|
17
|
+
|
18
|
+
- name: Install Rye
|
19
|
+
uses: eifinger/setup-rye@v4
|
20
|
+
with:
|
21
|
+
enable-cache: true
|
22
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
23
|
+
|
24
|
+
- name: Sync dependencies
|
25
|
+
run: rye sync
|
26
|
+
|
27
|
+
- name: Build distributions
|
28
|
+
run: rye build --clean
|
29
|
+
|
30
|
+
- name: Publish to PyPI
|
31
|
+
env:
|
32
|
+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
|
33
|
+
run: rye publish --token $PYPI_TOKEN --yes
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,213 @@
|
|
1
|
+
Metadata-Version: 2.3
|
2
|
+
Name: AtCoderStudyBooster
|
3
|
+
Version: 0.3.2
|
4
|
+
Summary: A tool to download and manage AtCoder problems.
|
5
|
+
Project-URL: Homepage, https://github.com/yuta6/AtCoderStudyBooster
|
6
|
+
Author-email: yuta6 <46110512+yuta6@users.noreply.github.com>
|
7
|
+
License: MIT
|
8
|
+
Requires-Python: >=3.8
|
9
|
+
Requires-Dist: beautifulsoup4
|
10
|
+
Requires-Dist: click-aliases>=1.0.5
|
11
|
+
Requires-Dist: markdownify>=0.13.1
|
12
|
+
Requires-Dist: pywebview>=5.4
|
13
|
+
Requires-Dist: questionary>=2.0.1
|
14
|
+
Requires-Dist: requests
|
15
|
+
Requires-Dist: rich-click>=1.8.8
|
16
|
+
Requires-Dist: rich>=13.7.1
|
17
|
+
Requires-Dist: tiktoken
|
18
|
+
Requires-Dist: types-beautifulsoup4>=4.12.0.20240511
|
19
|
+
Requires-Dist: types-requests>=2.32.0.20240712
|
20
|
+
Description-Content-Type: text/markdown
|
21
|
+
|
22
|
+
# AtCoderStudyBooster
|
23
|
+
|
24
|
+
## 概要
|
25
|
+
|
26
|
+
🚧 このプロジェクトはまだ実験段階です。日々のAtCoder学習に役立つ機能を順次追加しています。
|
27
|
+
|
28
|
+
AtCoderStudyBoosterはAtCoderの学習を加速させるためのCLIツールです。問題をローカルにダウンロードし、テスト、提出、解答の作成をサポートするツールです。Pythonが入っていることが必須です。Pythonが入っている環境なら、`pip install AtCoderStudyBooster`でインストールできます。(Python3.8以上が必要です)
|
29
|
+
|
30
|
+
キャプチャ認証が導入されたあとでも、CLIからほぼ自動でログイン&提出できます。ただしキャプチャを解くために、GUI環境が必要になる場合があります。
|
31
|
+
|
32
|
+
このツールは以下のプロジェクトに強く影響を受けています。
|
33
|
+
[online-judge-tools](https://github.com/online-judge-tools)
|
34
|
+
[atcoder-cli](https://github.com/Tatamo/atcoder-cli)
|
35
|
+
|
36
|
+
|
37
|
+
## 利用ケース
|
38
|
+
|
39
|
+
まずは`download`コマンドを利用して問題をローカルにダウンロードしてみましょう。
|
40
|
+
|
41
|
+
### B問題の練習したい場合
|
42
|
+
|
43
|
+
ABCコンテストの223から226のB問題だけを集中的に練習したい場合、次のコマンドを実行します。
|
44
|
+
|
45
|
+
```sh
|
46
|
+
❯ atcdr download B 223..226
|
47
|
+
```
|
48
|
+
|
49
|
+
コマンドを実行すると,次のようなフォルダーを作成して、各々のフォルダーに問題をダウンロードします。
|
50
|
+
|
51
|
+
```css
|
52
|
+
B
|
53
|
+
├── 223
|
54
|
+
│ ├── StringShifting.html
|
55
|
+
│ └── StringShifting.md
|
56
|
+
├── 224
|
57
|
+
│ ├── Mongeness.html
|
58
|
+
│ └── Mongeness.md
|
59
|
+
├── 225
|
60
|
+
│ ├── StarorNot.html
|
61
|
+
│ └── StarorNot.md
|
62
|
+
└── 226
|
63
|
+
├── CountingArrays.html
|
64
|
+
└── CountingArrays.md
|
65
|
+
```
|
66
|
+
|
67
|
+
### 特定のコンテストの問題に取り組みたい場合
|
68
|
+
|
69
|
+
```sh
|
70
|
+
❯ atcdr download 223..225 A..C
|
71
|
+
```
|
72
|
+
のように実行すると以下のようなフォルダーを生成します.
|
73
|
+
|
74
|
+
```css
|
75
|
+
.
|
76
|
+
├── 223
|
77
|
+
│ ├── A
|
78
|
+
│ │ ├── ExactPrice.html
|
79
|
+
│ │ └── ExactPrice.md
|
80
|
+
│ ├── B
|
81
|
+
│ │ ├── StringShifting.html
|
82
|
+
│ │ └── StringShifting.md
|
83
|
+
│ └── C
|
84
|
+
│ ├── Doukasen.html
|
85
|
+
│ └── Doukasen.md
|
86
|
+
├── 224
|
87
|
+
│ ├── A
|
88
|
+
│ │ ├── Tires.html
|
89
|
+
│ │ └── Tires.md
|
90
|
+
│ ├── B
|
91
|
+
│ │ ├── Mongeness.html
|
92
|
+
│ │ └── Mongeness.md
|
93
|
+
│ └── C
|
94
|
+
│ ├── Triangle.html
|
95
|
+
│ └── Triangle.md
|
96
|
+
└── 225
|
97
|
+
├── A
|
98
|
+
│ ├── DistinctStrings.html
|
99
|
+
│ └── DistinctStrings.md
|
100
|
+
├── B
|
101
|
+
│ ├── StarorNot.html
|
102
|
+
│ └── StarorNot.md
|
103
|
+
└── C
|
104
|
+
├── CalendarValidator.html
|
105
|
+
└── CalendarValidator.md
|
106
|
+
```
|
107
|
+
|
108
|
+
### 問題を解く
|
109
|
+
|
110
|
+
MarkdownファイルあるいはHTMLファイルをVS CodeのHTML Preview, Markdown Previewで開くと問題を確認できます。VS Codeで開くと左側にテキストエディターを表示して、右側で問題をみながら問題に取り組めます。
|
111
|
+
|
112
|
+

|
113
|
+
|
114
|
+
### サンプルをローカルでテストする
|
115
|
+
|
116
|
+
問題をダウンロードしたフォルダーに移動します。
|
117
|
+
|
118
|
+
```sh
|
119
|
+
❯ cd 224/B
|
120
|
+
```
|
121
|
+
|
122
|
+
移動したフォルダーで解答ファイルを作成後をtestコマンドを実行すると, サンプルケースをテストします。
|
123
|
+
|
124
|
+
```sh
|
125
|
+
~/.../224/B
|
126
|
+
❯ atcdr t
|
127
|
+
```
|
128
|
+
|
129
|
+

|
130
|
+
|
131
|
+
WAの場合は以下のような表示になります。
|
132
|
+
|
133
|
+

|
134
|
+
|
135
|
+
|
136
|
+
### 提出する
|
137
|
+
|
138
|
+
```sh
|
139
|
+
~/.../224/B
|
140
|
+
❯ atcdr s
|
141
|
+
```
|
142
|
+
を実行すると, 提出することができます。提出にはAtCoderのサイトへのログインが必要です。
|
143
|
+
|
144
|
+
### 解答をGPTで生成する
|
145
|
+
|
146
|
+
```sh
|
147
|
+
~/.../224/B
|
148
|
+
❯ atcdr g
|
149
|
+
```
|
150
|
+
で解答をGPTで生成します。Chat GPTのAPIキーが必要です。さらに、生成されたファイルはサンプルケースが自動でテストされ、**テストをパスしなかった場合、テスト結果がGPTにフィードバックされ解答が再生成**されます。
|
151
|
+
|
152
|
+
GPTとプログラムとのやり取りのログはJSONファイルで保存されます。
|
153
|
+
|
154
|
+
## 解答生成機能generateコマンドに関する注意点
|
155
|
+
|
156
|
+
[AtCoder生成AI対策ルール](https://info.atcoder.jp/entry/llm-rules-ja)によるとAtCoder Beginner Contest(以下、ABCとする)および AtCoder Regular Contest (Div. 2) においてに問題文を生成AIに直接与えることは禁止されています。ただし、このルールは過去問を練習している際には適用されません。 該当のコンテスト中にこの機能を使用しないでください。
|
157
|
+
|
158
|
+
## その他の機能
|
159
|
+
|
160
|
+
### markdownコマンド
|
161
|
+
|
162
|
+
完全なCLI環境方向けのコマンドです。
|
163
|
+
```sh
|
164
|
+
~/.../224/B
|
165
|
+
❯ atcdr md
|
166
|
+
```
|
167
|
+
を実行すると, 問題をプリントします。
|
168
|
+
|
169
|
+

|
170
|
+
|
171
|
+
### 複数のファイルを一度にテスト
|
172
|
+
|
173
|
+
```sh
|
174
|
+
~/.../224/B
|
175
|
+
❯ atcdr t *.py
|
176
|
+
```
|
177
|
+
でフォルダー内にあるすべてのPythonファイルを一度にテストします。
|
178
|
+
```sh
|
179
|
+
~/.../224/B
|
180
|
+
❯ atcdr t mon.py mon.c mon.cpp
|
181
|
+
```
|
182
|
+
|
183
|
+
フォルダー内に複数ファイルある場合は、インタラクティブに選択できます。
|
184
|
+
```sh
|
185
|
+
~/.../224/B
|
186
|
+
❯ atcdr t
|
187
|
+
```
|
188
|
+
|
189
|
+
```sh
|
190
|
+
~/.../224/B
|
191
|
+
❯ atcdr t
|
192
|
+
複数のファイルが見つかりました.ファイルを選択してください:
|
193
|
+
十字キーで移動, [enter]で実行
|
194
|
+
❯❯❯ mon.py
|
195
|
+
mon.c
|
196
|
+
mon.cpp
|
197
|
+
```
|
198
|
+
|
199
|
+
### プログラミング言語を指定してコードを生成
|
200
|
+
|
201
|
+
`--lang`オプションを使うと、生成したいプログラミング言語を指定できます。
|
202
|
+
```sh
|
203
|
+
~/.../224/B
|
204
|
+
❯ atcdr generate --lang rust
|
205
|
+
```
|
206
|
+
### テストをせずにコードのみ生成
|
207
|
+
|
208
|
+
デフォルトで`atcdr generate`コマンドは生成されたコードをテストしますが、テストせずにコードのみ生成できます。
|
209
|
+
|
210
|
+
```sh
|
211
|
+
~/.../224/B
|
212
|
+
❯ atcdr generate --lang rust --without_test
|
213
|
+
```
|
@@ -0,0 +1,192 @@
|
|
1
|
+
# AtCoderStudyBooster
|
2
|
+
|
3
|
+
## 概要
|
4
|
+
|
5
|
+
🚧 このプロジェクトはまだ実験段階です。日々のAtCoder学習に役立つ機能を順次追加しています。
|
6
|
+
|
7
|
+
AtCoderStudyBoosterはAtCoderの学習を加速させるためのCLIツールです。問題をローカルにダウンロードし、テスト、提出、解答の作成をサポートするツールです。Pythonが入っていることが必須です。Pythonが入っている環境なら、`pip install AtCoderStudyBooster`でインストールできます。(Python3.8以上が必要です)
|
8
|
+
|
9
|
+
キャプチャ認証が導入されたあとでも、CLIからほぼ自動でログイン&提出できます。ただしキャプチャを解くために、GUI環境が必要になる場合があります。
|
10
|
+
|
11
|
+
このツールは以下のプロジェクトに強く影響を受けています。
|
12
|
+
[online-judge-tools](https://github.com/online-judge-tools)
|
13
|
+
[atcoder-cli](https://github.com/Tatamo/atcoder-cli)
|
14
|
+
|
15
|
+
|
16
|
+
## 利用ケース
|
17
|
+
|
18
|
+
まずは`download`コマンドを利用して問題をローカルにダウンロードしてみましょう。
|
19
|
+
|
20
|
+
### B問題の練習したい場合
|
21
|
+
|
22
|
+
ABCコンテストの223から226のB問題だけを集中的に練習したい場合、次のコマンドを実行します。
|
23
|
+
|
24
|
+
```sh
|
25
|
+
❯ atcdr download B 223..226
|
26
|
+
```
|
27
|
+
|
28
|
+
コマンドを実行すると,次のようなフォルダーを作成して、各々のフォルダーに問題をダウンロードします。
|
29
|
+
|
30
|
+
```css
|
31
|
+
B
|
32
|
+
├── 223
|
33
|
+
│ ├── StringShifting.html
|
34
|
+
│ └── StringShifting.md
|
35
|
+
├── 224
|
36
|
+
│ ├── Mongeness.html
|
37
|
+
│ └── Mongeness.md
|
38
|
+
├── 225
|
39
|
+
│ ├── StarorNot.html
|
40
|
+
│ └── StarorNot.md
|
41
|
+
└── 226
|
42
|
+
├── CountingArrays.html
|
43
|
+
└── CountingArrays.md
|
44
|
+
```
|
45
|
+
|
46
|
+
### 特定のコンテストの問題に取り組みたい場合
|
47
|
+
|
48
|
+
```sh
|
49
|
+
❯ atcdr download 223..225 A..C
|
50
|
+
```
|
51
|
+
のように実行すると以下のようなフォルダーを生成します.
|
52
|
+
|
53
|
+
```css
|
54
|
+
.
|
55
|
+
├── 223
|
56
|
+
│ ├── A
|
57
|
+
│ │ ├── ExactPrice.html
|
58
|
+
│ │ └── ExactPrice.md
|
59
|
+
│ ├── B
|
60
|
+
│ │ ├── StringShifting.html
|
61
|
+
│ │ └── StringShifting.md
|
62
|
+
│ └── C
|
63
|
+
│ ├── Doukasen.html
|
64
|
+
│ └── Doukasen.md
|
65
|
+
├── 224
|
66
|
+
│ ├── A
|
67
|
+
│ │ ├── Tires.html
|
68
|
+
│ │ └── Tires.md
|
69
|
+
│ ├── B
|
70
|
+
│ │ ├── Mongeness.html
|
71
|
+
│ │ └── Mongeness.md
|
72
|
+
│ └── C
|
73
|
+
│ ├── Triangle.html
|
74
|
+
│ └── Triangle.md
|
75
|
+
└── 225
|
76
|
+
├── A
|
77
|
+
│ ├── DistinctStrings.html
|
78
|
+
│ └── DistinctStrings.md
|
79
|
+
├── B
|
80
|
+
│ ├── StarorNot.html
|
81
|
+
│ └── StarorNot.md
|
82
|
+
└── C
|
83
|
+
├── CalendarValidator.html
|
84
|
+
└── CalendarValidator.md
|
85
|
+
```
|
86
|
+
|
87
|
+
### 問題を解く
|
88
|
+
|
89
|
+
MarkdownファイルあるいはHTMLファイルをVS CodeのHTML Preview, Markdown Previewで開くと問題を確認できます。VS Codeで開くと左側にテキストエディターを表示して、右側で問題をみながら問題に取り組めます。
|
90
|
+
|
91
|
+

|
92
|
+
|
93
|
+
### サンプルをローカルでテストする
|
94
|
+
|
95
|
+
問題をダウンロードしたフォルダーに移動します。
|
96
|
+
|
97
|
+
```sh
|
98
|
+
❯ cd 224/B
|
99
|
+
```
|
100
|
+
|
101
|
+
移動したフォルダーで解答ファイルを作成後をtestコマンドを実行すると, サンプルケースをテストします。
|
102
|
+
|
103
|
+
```sh
|
104
|
+
~/.../224/B
|
105
|
+
❯ atcdr t
|
106
|
+
```
|
107
|
+
|
108
|
+

|
109
|
+
|
110
|
+
WAの場合は以下のような表示になります。
|
111
|
+
|
112
|
+

|
113
|
+
|
114
|
+
|
115
|
+
### 提出する
|
116
|
+
|
117
|
+
```sh
|
118
|
+
~/.../224/B
|
119
|
+
❯ atcdr s
|
120
|
+
```
|
121
|
+
を実行すると, 提出することができます。提出にはAtCoderのサイトへのログインが必要です。
|
122
|
+
|
123
|
+
### 解答をGPTで生成する
|
124
|
+
|
125
|
+
```sh
|
126
|
+
~/.../224/B
|
127
|
+
❯ atcdr g
|
128
|
+
```
|
129
|
+
で解答をGPTで生成します。Chat GPTのAPIキーが必要です。さらに、生成されたファイルはサンプルケースが自動でテストされ、**テストをパスしなかった場合、テスト結果がGPTにフィードバックされ解答が再生成**されます。
|
130
|
+
|
131
|
+
GPTとプログラムとのやり取りのログはJSONファイルで保存されます。
|
132
|
+
|
133
|
+
## 解答生成機能generateコマンドに関する注意点
|
134
|
+
|
135
|
+
[AtCoder生成AI対策ルール](https://info.atcoder.jp/entry/llm-rules-ja)によるとAtCoder Beginner Contest(以下、ABCとする)および AtCoder Regular Contest (Div. 2) においてに問題文を生成AIに直接与えることは禁止されています。ただし、このルールは過去問を練習している際には適用されません。 該当のコンテスト中にこの機能を使用しないでください。
|
136
|
+
|
137
|
+
## その他の機能
|
138
|
+
|
139
|
+
### markdownコマンド
|
140
|
+
|
141
|
+
完全なCLI環境方向けのコマンドです。
|
142
|
+
```sh
|
143
|
+
~/.../224/B
|
144
|
+
❯ atcdr md
|
145
|
+
```
|
146
|
+
を実行すると, 問題をプリントします。
|
147
|
+
|
148
|
+

|
149
|
+
|
150
|
+
### 複数のファイルを一度にテスト
|
151
|
+
|
152
|
+
```sh
|
153
|
+
~/.../224/B
|
154
|
+
❯ atcdr t *.py
|
155
|
+
```
|
156
|
+
でフォルダー内にあるすべてのPythonファイルを一度にテストします。
|
157
|
+
```sh
|
158
|
+
~/.../224/B
|
159
|
+
❯ atcdr t mon.py mon.c mon.cpp
|
160
|
+
```
|
161
|
+
|
162
|
+
フォルダー内に複数ファイルある場合は、インタラクティブに選択できます。
|
163
|
+
```sh
|
164
|
+
~/.../224/B
|
165
|
+
❯ atcdr t
|
166
|
+
```
|
167
|
+
|
168
|
+
```sh
|
169
|
+
~/.../224/B
|
170
|
+
❯ atcdr t
|
171
|
+
複数のファイルが見つかりました.ファイルを選択してください:
|
172
|
+
十字キーで移動, [enter]で実行
|
173
|
+
❯❯❯ mon.py
|
174
|
+
mon.c
|
175
|
+
mon.cpp
|
176
|
+
```
|
177
|
+
|
178
|
+
### プログラミング言語を指定してコードを生成
|
179
|
+
|
180
|
+
`--lang`オプションを使うと、生成したいプログラミング言語を指定できます。
|
181
|
+
```sh
|
182
|
+
~/.../224/B
|
183
|
+
❯ atcdr generate --lang rust
|
184
|
+
```
|
185
|
+
### テストをせずにコードのみ生成
|
186
|
+
|
187
|
+
デフォルトで`atcdr generate`コマンドは生成されたコードをテストしますが、テストせずにコードのみ生成できます。
|
188
|
+
|
189
|
+
```sh
|
190
|
+
~/.../224/B
|
191
|
+
❯ atcdr generate --lang rust --without_test
|
192
|
+
```
|
@@ -0,0 +1,86 @@
|
|
1
|
+
from importlib.metadata import metadata
|
2
|
+
|
3
|
+
import rich_click as click
|
4
|
+
from click_aliases import ClickAliasedGroup
|
5
|
+
from rich.console import Console
|
6
|
+
from rich.panel import Panel
|
7
|
+
from rich.table import Table
|
8
|
+
from rich.traceback import install
|
9
|
+
from rich_click import RichGroup
|
10
|
+
|
11
|
+
from atcdr.download import download
|
12
|
+
from atcdr.generate import generate
|
13
|
+
from atcdr.login import login
|
14
|
+
from atcdr.logout import logout
|
15
|
+
from atcdr.markdown import markdown
|
16
|
+
from atcdr.open import open_files
|
17
|
+
from atcdr.submit import submit
|
18
|
+
from atcdr.test import test
|
19
|
+
|
20
|
+
|
21
|
+
# ─── RichClick + ClickAliases 両対応の Group クラス ───
|
22
|
+
class AliasedRichGroup(ClickAliasedGroup, RichGroup):
|
23
|
+
def format_commands(self, ctx, console, *args, **kwargs):
|
24
|
+
console = Console()
|
25
|
+
commands = self.list_commands(ctx)
|
26
|
+
|
27
|
+
table = Table(show_header=False, box=None, pad_edge=False)
|
28
|
+
table.add_column('command', style='bold cyan', no_wrap=True)
|
29
|
+
table.add_column('help', style='')
|
30
|
+
|
31
|
+
for name in commands:
|
32
|
+
cmd = self.get_command(ctx, name)
|
33
|
+
if not cmd or getattr(cmd, 'hidden', False):
|
34
|
+
continue
|
35
|
+
|
36
|
+
aliases = self._commands.get(name, [])
|
37
|
+
alias_part = f"[dim]({', '.join(aliases)})[/]" if aliases else ''
|
38
|
+
|
39
|
+
short = (
|
40
|
+
cmd.get_short_help_str()
|
41
|
+
if hasattr(cmd, 'get_short_help_str')
|
42
|
+
else cmd.short_help or ''
|
43
|
+
)
|
44
|
+
table.add_row(f'{name}{alias_part}', short)
|
45
|
+
|
46
|
+
panel = Panel(table, title='Commands', expand=False)
|
47
|
+
console.print(panel)
|
48
|
+
|
49
|
+
|
50
|
+
# ─── CLI 定義 ──────────────────────────────────────────
|
51
|
+
_meta = metadata('AtCoderStudyBooster')
|
52
|
+
_NAME = _meta['Name']
|
53
|
+
_VERSION = _meta['Version']
|
54
|
+
|
55
|
+
click.rich_click.MAX_WIDTH = 100
|
56
|
+
click.rich_click.SHOW_ARGUMENTS = True
|
57
|
+
click.rich_click.STYLE_HELPTEXT_FIRST_LINE = 'bold cyan'
|
58
|
+
click.rich_click.STYLE_HELPTEXT = 'dim'
|
59
|
+
|
60
|
+
|
61
|
+
@click.group(
|
62
|
+
cls=AliasedRichGroup,
|
63
|
+
context_settings={'help_option_names': ['-h', '--help']},
|
64
|
+
)
|
65
|
+
@click.version_option(
|
66
|
+
_VERSION,
|
67
|
+
'-v',
|
68
|
+
'--version',
|
69
|
+
prog_name=_NAME,
|
70
|
+
message='%(prog)s %(version)s',
|
71
|
+
)
|
72
|
+
def cli():
|
73
|
+
install()
|
74
|
+
|
75
|
+
|
76
|
+
cli.add_command(test, aliases=['t'])
|
77
|
+
cli.add_command(download, aliases=['d'])
|
78
|
+
cli.add_command(open_files, 'open', aliases=['o'])
|
79
|
+
cli.add_command(generate, aliases=['g'])
|
80
|
+
cli.add_command(markdown, aliases=['md'])
|
81
|
+
cli.add_command(submit, aliases=['s'])
|
82
|
+
cli.add_command(login)
|
83
|
+
cli.add_command(logout)
|
84
|
+
|
85
|
+
if __name__ == '__main__':
|
86
|
+
cli()
|