Skip to content

Commit

Permalink
Include memory feature in CLI commands
Browse files Browse the repository at this point in the history
  • Loading branch information
dormant-user committed Jan 1, 2025
1 parent 875372d commit af79f1d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pyarchitecture/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def commandline() -> None:
disk_info = "disk" in sys.argv
cpu_info = "cpu" in sys.argv
gpu_info = "gpu" in sys.argv
mem_info = "memory" in sys.argv
all_info = "all" in sys.argv
save_info = "save" in sys.argv

Expand All @@ -65,9 +66,11 @@ def commandline() -> None:
options = {
"--version | -V": "Prints the version.",
"--help | -H": "Prints the help section.",
"all": "Prints the entire system information in the terminal.",
"disk": "Prints the disk information in the terminal.",
"cpu": "Prints the CPU name in the terminal.",
"gpu": "Prints the GPU information in the terminal.",
"memory": "Prints the RAM/memory information in the terminal.",
"save": "Saves the chosen information into a JSON file.",
"--filename": "Filename to store the information.",
}
Expand All @@ -92,6 +95,9 @@ def commandline() -> None:
if gpu_info and not save_info:
pprint.pprint(gpu.get_gpu_names())
sys.exit(0)
if mem_info and not save_info:
pprint.pprint(memory.get_memory_info())
sys.exit(0)

if not any([disk_info, cpu_info, gpu_info]):
save_info = False
Expand All @@ -108,6 +114,8 @@ def commandline() -> None:
data["GPU"] = gpu.get_gpu_names()
if disk_info:
data["Disks"] = disks.get_all_disks()
if mem_info:
data["Memory"] = memory.get_memory_info()

with open(filename, "w") as json_file:
json.dump(data, json_file, indent=2)
Expand Down

0 comments on commit af79f1d

Please sign in to comment.