-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflupy.py
More file actions
53 lines (33 loc) · 1.07 KB
/
flupy.py
File metadata and controls
53 lines (33 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import typer
import os
from colorama import Fore, Style
from pathlib import Path
app = typer.Typer()
projects_dirs = []
def generate_flutter_projects_directories(directory):
global projects_dirs
projects_dirs = []
cwd = os.getcwd()
pwd = Path(cwd).joinpath(directory)
dirs = list(filter(lambda d: d.is_dir(), pwd.iterdir()))
for d in dirs:
if "pubspec.yaml" in os.listdir(d):
projects_dirs.append(d)
def run_command(command: str, directory: str):
cwd = os.getcwd()
pwd = Path(cwd).joinpath(directory)
for d in projects_dirs:
os.chdir(pwd.joinpath(d))
print(f"{Fore.GREEN}>> {d} <<{Style.RESET_ALL}")
os.system(command)
os.chdir(pwd)
@app.command()
def clean(directory):
generate_flutter_projects_directories(directory)
run_command("flutter clean", directory)
@app.command()
def get(directory):
generate_flutter_projects_directories(directory)
run_command("flutter pub get", directory)
if __name__ == "__main__":
app()