9
9
from rich .logging import RichHandler
10
10
from rich .style import Style
11
11
12
- from pyfuture .utils import transfer_file
12
+ from pyfuture .utils import get_target , transfer_file
13
13
14
14
app = typer .Typer ()
15
15
@@ -21,21 +21,21 @@ def init_logger(log_level: str):
21
21
22
22
23
23
@app .command ()
24
- def transfer (src_file : Path , tgt_file : Path , * , target : str = "3.9 " , log_level : str = "INFO" ):
24
+ def transfer (src_file : Path , tgt_file : Path , * , target : str = "py39 " , log_level : str = "INFO" ):
25
25
"""
26
26
Transfer code from src_file and write to tgt_file.
27
27
"""
28
- assert target == "3.9" , "PyFuture is very early stage, not support target argument yet"
28
+
29
29
init_logger (log_level )
30
30
transfer_file (src_file , tgt_file )
31
31
32
32
33
33
@app .command ()
34
- def watch (src_file : Path , tgt_file : Path , * , target : str = "3.9 " , log_level : str = "INFO" ): # pragma: no cover
34
+ def watch (src_file : Path , tgt_file : Path , * , target : str = "py39 " , log_level : str = "INFO" ): # pragma: no cover
35
35
"""
36
36
Transfer all python files in src_dir to build_dir, and watch for changes.
37
37
"""
38
- assert target == "3.9" , "PyFuture is very early stage, not support target argument yet"
38
+
39
39
init_logger (log_level )
40
40
transfer_file (src_file , tgt_file )
41
41
@@ -46,18 +46,18 @@ def watch(src_file: Path, tgt_file: Path, *, target: str = "3.9", log_level: str
46
46
match mode :
47
47
case Change .modified :
48
48
logger .info ("Source file has been modified" )
49
- transfer_file (Path (path ), tgt_file )
49
+ transfer_file (Path (path ), tgt_file , target = get_target ( target ) )
50
50
case Change .deleted :
51
51
logger .info ("Source file has been deleted" )
52
52
break
53
53
54
54
55
55
@app .command ()
56
- def transfer_dir (src_dir : Path , build_dir : Path , * , target : str = "3.9 " , log_level : str = "INFO" ):
56
+ def transfer_dir (src_dir : Path , build_dir : Path , * , target : str = "py39 " , log_level : str = "INFO" ):
57
57
"""
58
58
Transfer all python files in src_dir to build_dir.
59
59
"""
60
- assert target == "3.9" , "PyFuture is very early stage, not support target argument yet"
60
+
61
61
init_logger (log_level )
62
62
63
63
for src_file in src_dir .glob ("**/*.py" ):
@@ -66,11 +66,11 @@ def transfer_dir(src_dir: Path, build_dir: Path, *, target: str = "3.9", log_lev
66
66
67
67
68
68
@app .command ()
69
- def watch_dir (src_dir : Path , build_dir : Path , * , target : str = "3.9 " , log_level : str = "INFO" ): # pragma: no cover
69
+ def watch_dir (src_dir : Path , build_dir : Path , * , target : str = "py39 " , log_level : str = "INFO" ): # pragma: no cover
70
70
"""
71
71
Transfer all python files in src_dir to build_dir, and watch for changes.
72
72
"""
73
- assert target == "3.9" , "PyFuture is very early stage, not support target argument yet"
73
+
74
74
init_logger (log_level )
75
75
transfer_dir (src_dir , build_dir , target = target )
76
76
0 commit comments