-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c146c8
commit 00b19f9
Showing
4 changed files
with
75 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,25 @@ | ||
#!/usr/bin/env python | ||
|
||
import click | ||
from src import app, VERSION, config | ||
from src import app, VERSION | ||
|
||
|
||
@click.command() | ||
@click.option('--test', is_flag=True, help='Run testing function', default=False, ) | ||
@click.option('--version', '-v', is_flag=True, help='Check version', default=False, ) | ||
@click.option('--update', is_flag=True, help='Check for update', default=False, ) | ||
@click.option('--show-command', is_flag=True, help='Show Command', default=False, ) | ||
@click.argument('input', type=click.File('r'), default=None, required=False) | ||
def exec(test: str, version: str, update: str, show_command: bool, input: click.File): | ||
config.app["show-command"] = show_command | ||
|
||
if test: | ||
app.test() | ||
elif version: | ||
print(f'v: {VERSION}') | ||
elif update: | ||
app.update() | ||
else: | ||
name = input.name if input else None | ||
files = [name] if name else [] | ||
app.main(files) | ||
def exec(test: str, version: str, update: str, input: click.File): | ||
if test: | ||
app.test() | ||
elif version: | ||
print(f'v: {VERSION}') | ||
elif update: | ||
app.update() | ||
else: | ||
name = input.name if input else None | ||
files = [name] if name else [] | ||
app.main(files) | ||
|
||
|
||
exec() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,44 @@ | ||
import src.event as event | ||
import src.loader as loader | ||
import src.utils as utils | ||
import src.config as config | ||
from rich import print | ||
from rich.panel import Panel | ||
from rich.syntax import Syntax | ||
import time | ||
|
||
|
||
def manage(cmds: list[str]): | ||
loader.loader.start() | ||
loader.loader.start() | ||
|
||
def handle_progress(cmd: str, percent: int): | ||
loader.loader.update(utils.hash(cmd), percent) | ||
all_task_name = f"all ({len(cmds)})" | ||
|
||
def get_process(cmd: str): | ||
return event.ProcessWithEvent(cmd, progress_cb=handle_progress) | ||
loader.loader.add_task(all_task_name, len(cmds)) | ||
loader.loader.add_task("current", 100) | ||
|
||
pwe_list = list(map(get_process, cmds)) | ||
def handle_progress(cmd: str, percent: int): | ||
loader.loader.update("current", percent) | ||
|
||
for pwe in pwe_list: | ||
loader.loader.add_task(utils.hash(pwe.cmd), 100) | ||
for i in range(len(cmds)): | ||
loader.loader.update("current", 0) | ||
cmd = cmds[i] | ||
time.sleep(0.01) | ||
p = event.ProcessWithEvent(cmd, progress_cb=handle_progress) | ||
p.start() | ||
|
||
for pwe in pwe_list: | ||
if config.app['show-command']: | ||
syntax = Syntax(pwe.cmd, "bash", theme="monokai", word_wrap=True) | ||
panel = Panel(syntax, title="Command", ) | ||
print(panel) | ||
loader.loader.update(all_task_name, i + 1) | ||
|
||
pwe.start() | ||
|
||
loader.loader.stop() | ||
loader.loader.stop() | ||
|
||
|
||
def main(): | ||
|
||
cmd1 = "source /Users/tahsin/.commonrc && hb_test 10" | ||
cmd2 = "source /Users/tahsin/.commonrc && hb_test 12" | ||
cmd3 = "source /Users/tahsin/.commonrc && hb_test 5" | ||
cmd4 = "ls" | ||
cmds = [] | ||
|
||
cmds = [cmd1, cmd2, cmd3, cmd4] | ||
for i in range(1000): | ||
cmds.append("ls") | ||
|
||
manage(cmds) | ||
manage(cmds) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() | ||
main() |