Add --version argument

This commit is contained in:
Matt Martz 2013-09-16 13:07:24 -05:00
parent c3601a046b
commit cea8426fcd
1 changed files with 11 additions and 0 deletions

View File

@ -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()