Skip to content

Commit dd4f857

Browse files
committed
update and upload pypi
1 parent 851591d commit dd4f857

File tree

8 files changed

+39
-2484
lines changed

8 files changed

+39
-2484
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,7 @@ venv.bak/
103103
# mypy
104104
.mypy_cache/
105105

106-
# add
106+
# idea
107107
.idea/
108+
109+
poetry.lock

README.md

Lines changed: 4 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,17 @@
11
# FastAPI Project Clone CLI
22

3-
> Ps: 浅用 [Typer](https://typer.tiangolo.com/)
3+
> 此程序使用 [Typer](https://typer.tiangolo.com/) 创建
44
55
## 使用
66

7-
###### P.S.: 未上传到 PyPi, 两种方式选其一, 按步骤在命令行执行即可
8-
9-
### 1. 克隆仓库
10-
11-
clone
12-
13-
```shell
14-
git clone https://gitee.com/wu_cl/fastapi_ccli
15-
```
16-
17-
install dep
18-
19-
```shell
20-
poetry install
21-
```
22-
23-
help
7+
pip 安装:
248

259
```shell
26-
# 进入 fastapi_ccli 目录下
27-
28-
python main.py --help
10+
pip install fastapi-ccli
2911
```
3012

31-
run
13+
查看使用帮助
3214

3315
```shell
34-
# 进入 fastapi_ccli 目录下
35-
36-
python main.py
37-
```
38-
39-
---
40-
41-
### 2. 安装 whl 包
42-
43-
install whl
44-
45-
[点击下载](https://gitee.com/wu_cl/fastapi_ccli/raw/master/dist/fastapi_ccli-0.0.1-py3-none-any.whl)
46-
47-
[备用1](https://github.com/wu-clan/fastapi_ccli/blob/master/dist/fastapi_ccli-0.0.1-py3-none-any.whl?raw=true)
48-
49-
[备用2](https://minhaskamal.github.io/DownGit/#/home?url=https://github.com/wu-clan/fastapi_ccli/blob/master/dist/fastapi_ccli-0.0.1-py3-none-any.whl)
50-
51-
pip install
52-
53-
```shell
54-
# 在 whl 包存放目录执行:
55-
56-
pip install fastapi_ccli-0.0.1-py3-none-any.whl
57-
```
58-
59-
help
60-
61-
```shell
62-
# 任意终端下执行
63-
6416
fastapi-ccli --help
6517
```
66-
67-
run
68-
69-
```shell
70-
# 任意终端下执行
71-
72-
fastapi-ccli
73-
```
74-
75-
## 测试
76-
77-
根目录下执行 `pytest`
-13.8 KB
Binary file not shown.

fastapi_ccli/main.py

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,42 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33
import sys
4-
from pathlib import Path
54

65
import questionary
7-
import typer
86

9-
sys.path.append(str(Path(__file__).resolve().parent.parent))
10-
11-
from fastapi_ccli.CN.cloner_zh import app_zh
12-
from fastapi_ccli.CN.cloner_zh_form import app_zh_form
13-
from fastapi_ccli.EN.cloner_en import app_en
14-
from fastapi_ccli.EN.cloner_en_form import app_en_form
7+
from fastapi_ccli.cloner.en.cloner_en import app_en
8+
from fastapi_ccli.cloner.en.cloner_en_form import app_en_form
9+
from fastapi_ccli.cloner.version import version
10+
from fastapi_ccli.cloner.zh.cloner_zh import app_zh
11+
from fastapi_ccli.cloner.zh.cloner_zh_form import app_zh_form
1512

1613

1714
def main():
15+
if len(sys.argv) > 1:
16+
if any(sys.argv[1] == _ for _ in ['--version', '-V']):
17+
version()
1818
select_language = questionary.form(
19-
language = questionary.select('Please select your language:', choices=['zh-hans', 'en'], default='en')
20-
).unsafe_ask()
21-
if select_language['language'] == 'zh-hans':
22-
interactive_zh = typer.confirm('是否以交互模式运行?', default=True)
23-
if interactive_zh:
19+
language=questionary.select('Please select your language:', choices=['zh-hans', 'en'], default='en')
20+
).ask()
21+
if len(select_language) == 0:
22+
sys.exit(0)
23+
elif select_language['language'] == 'zh-hans':
24+
select_run_type = questionary.form(
25+
interactive=questionary.select('是否以交互模式运行?', choices=['yes', 'no'], default='yes')
26+
).ask()
27+
if len(select_run_type) == 0:
28+
sys.exit(0)
29+
if select_run_type.get('interactive') == 'yes':
2430
app_zh_form()
2531
else:
2632
app_zh()
2733
else:
28-
interactive_en = typer.confirm('Whether to run in interactive mode?', default=True)
29-
if interactive_en:
34+
select_run_type = questionary.form(
35+
interactive=questionary.select('Whether to run in interactive mode?', choices=['yes', 'no'], default='yes')
36+
).ask()
37+
if len(select_run_type) == 0:
38+
sys.exit(0)
39+
if select_run_type.get('interactive') == 'yes':
3040
app_en_form()
3141
else:
3242
app_en()
33-
34-
35-
if __name__ == '__main__':
36-
main()

fastapi_ccli/utils/get_country.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def get_current_country(ip: Union[str, None]) -> str:
1818
rp = request.get(f'https://ip.useragentinfo.com/json?ip={ip}', proxies=proxy).json()['short_name']
1919
else:
2020
rp = request.get(f'https://ip.useragentinfo.com/json?ip=', proxies=proxy).json()['short_name']
21-
except Exception:
21+
except Exception: # noqa
2222
rp = 'Unknown'
2323

2424
return rp

fastapi_ccli/utils/get_ip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def get_net_ip() -> str:
1919
ip = request.get('https://api.ipify.org/').text.strip()
2020
if not ip:
2121
ip = request.get('https://ip.42.pl/raw').text.strip()
22-
except Exception:
22+
except Exception: # noqa
2323
ip = None
2424

2525
return ip

0 commit comments

Comments
 (0)