From cea8426fcd7754d18b114a90faaac711fa278e60 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Mon, 16 Sep 2013 13:07:24 -0500 Subject: [PATCH] Add --version argument --- speedtest_cli.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/speedtest_cli.py b/speedtest_cli.py index 963a184..9f9fc9c 100755 --- a/speedtest_cli.py +++ b/speedtest_cli.py @@ -15,6 +15,8 @@ # License for the specific language governing permissions and limitations # under the License. +__version__ = '0.2.1' + try: from urllib2 import urlopen, Request except ImportError: @@ -346,6 +348,10 @@ def ctrl_c(signum, frame): raise SystemExit('\nCancelling...') +def version(): + raise SystemExit(__version__) + + def speedtest(): """Run the full speedtest.net test""" @@ -377,6 +383,8 @@ def speedtest(): 'sorted by distance') parser.add_argument('--server', help='Specify a server ID to test against') parser.add_argument('--mini', help='URL of the Speedtest Mini server') + parser.add_argument('--version', action='store_true', + help='Show the version number and exit') options = parser.parse_args() if isinstance(options, tuple): @@ -385,6 +393,9 @@ def speedtest(): args = options del options + if args.version: + version() + if not args.simple: print_('Retrieving speedtest.net configuration...') config = getConfig()