diff --git a/asitop/__main__.py b/asitop/__main__.py new file mode 100644 index 0000000..168ba7b --- /dev/null +++ b/asitop/__main__.py @@ -0,0 +1,22 @@ +import argparse +from asitop.asitop import main + +parser = argparse.ArgumentParser( + description='asitop: Performance monitoring CLI tool for Apple Silicon') +parser.add_argument('--interval', type=int, default=1, + help='Display interval and sampling interval for powermetrics (seconds)') +parser.add_argument('--color', type=int, default=2, + help='Choose display color (0~8)') +parser.add_argument('--avg', type=int, default=30, + help='Interval for averaged values (seconds)') +parser.add_argument('--show_cores', type=bool, default=False, + help='Choose show cores mode') + +powermetrics_process = main(parser.parse_args()) +try: + powermetrics_process.terminate() + print("Successfully terminated powermetrics process") +except Exception as e: + print(e) + powermetrics_process.terminate() + print("Successfully terminated powermetrics process") diff --git a/asitop/asitop.py b/asitop/asitop.py index 324aa8e..6d59877 100644 --- a/asitop/asitop.py +++ b/asitop/asitop.py @@ -1,23 +1,10 @@ import time -import argparse from collections import deque from dashing import VSplit, HSplit, HGauge, HChart, VGauge -from .utils import * - -parser = argparse.ArgumentParser( - description='asitop: Performance monitoring CLI tool for Apple Silicon') -parser.add_argument('--interval', type=int, default=1, - help='Display interval and sampling interval for powermetrics (seconds)') -parser.add_argument('--color', type=int, default=2, - help='Choose display color (0~8)') -parser.add_argument('--avg', type=int, default=30, - help='Interval for averaged values (seconds)') -parser.add_argument('--show_cores', type=bool, default=False, - help='Choose show cores mode') -args = parser.parse_args() - - -def main(): +from asitop.utils import * + + +def main(args): print("\nASITOP - Performance monitoring CLI tool for Apple Silicon") print("You can update ASITOP by running `pip install asitop --upgrade`") print("Get help at `https://github.com/tlkh/asitop`") @@ -390,14 +377,3 @@ def get_avg(inlist): print("Stopping...") return powermetrics_process - - -if __name__ == "__main__": - powermetrics_process = main() - try: - powermetrics_process.terminate() - print("Successfully terminated powermetrics process") - except Exception as e: - print(e) - powermetrics_process.terminate() - print("Successfully terminated powermetrics process")