From 46cfcf0221fe4e5ca1783e257d952109656d56be Mon Sep 17 00:00:00 2001 From: Divarion-D Date: Sun, 25 Jan 2026 13:09:00 +0300 Subject: [PATCH] Added --version parameter to check binary file after build --- src/bin/network.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/bin/network.py b/src/bin/network.py index aae298e..746057d 100644 --- a/src/bin/network.py +++ b/src/bin/network.py @@ -1,6 +1,8 @@ import json import time +import argparse +VERSION = "1.0.0" def parse_line(line): """Parse a line from /proc/net/dev into a dictionary of interface statistics.""" @@ -82,15 +84,27 @@ def stats_display(prev_stats, current_stats): def main(): - """Main function to monitor network statistics continuously.""" + parser = argparse.ArgumentParser(description="Network statistics monitor") + parser.add_argument( + "--version", + "-v", + action="store_true", + help="Show program version and exit" + ) + args = parser.parse_args() + + if args.version: + print(f"Network statistics monitor {VERSION}") + return + # Initial reading prev_stats = stats_read() - # Continuous monitoring loop + try: while True: - time.sleep(2) # Sleep for 2 seconds as per the original code + time.sleep(2) current_stats = stats_read() - if current_stats: # Only proceed if reading was successful + if current_stats: stats_display(prev_stats, current_stats) prev_stats = current_stats except KeyboardInterrupt: