-
Notifications
You must be signed in to change notification settings - Fork 25
/
command_line_script.py
executable file
·69 lines (62 loc) · 2.05 KB
/
command_line_script.py
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python3
import os
import typer
from typing import Optional
from Simulator import Type
import time
def autotype_cli(
path: Optional[str] = typer.Option(
default="",
help=typer.style("the path to the file 🗂", fg=typer.colors.MAGENTA),
prompt=True,
confirmation_prompt=True,
show_default="Empty File Path",
),
delay: Optional[int] = typer.Option(
default=3,
help=typer.style(
"time ⌛️ delay before typing (in seconds)", fg=typer.colors.MAGENTA
),
show_default=3,
prompt=True,
),
):
"""
A quick and small python script that helps you autotype on websites that have copy paste disabled like Moodle, HackerEarth contests etc as it is difficult to efficiently debug your code on an online compiler.
--path: the path to the file.
--delay: time delay before typing.
return: Prints the File Given.
"""
if path and not os.path.isfile(path):
file_path = typer.style(
f"{path}",
fg=typer.colors.BRIGHT_WHITE,
bg=typer.colors.BRIGHT_RED,
bold=True,
)
error_message = typer.style(
"is not found Please Specify the correct Path.", fg=typer.colors.RED
)
typer.echo(f"{file_path + ' ' + error_message} ")
raise typer.Exit(code=0)
else:
total = 0
with typer.progressbar(
range(100),
label=typer.style(
"Writing File in Progress -> ", fg=typer.colors.GREEN, bold=True
),
) as progress:
for value in progress:
time.sleep(0.01)
total += 1
Type(path, delay)
successfull_file_path = typer.style(
f"{path} File", fg=typer.colors.BRIGHT_GREEN
)
time_taken = typer.style(
f"is written in {abs(delay)} seconds", fg=typer.colors.BRIGHT_WHITE
)
typer.echo(f"{successfull_file_path + ' ' + time_taken}")
if __name__ == "__main__":
typer.run(autotype_cli)