Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat: add argument to get the current version
  • Loading branch information
Jérôme Deuchnord committed Nov 18, 2019
1 parent 2b26e44 commit 5f74b08
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions kosmorro
Expand Up @@ -20,6 +20,7 @@ import argparse
import sys
from datetime import date

from kosmorrolib.version import VERSION
from kosmorrolib import dumper
from kosmorrolib import core
from kosmorrolib.ephemerides import EphemeridesComputer, Position
Expand Down Expand Up @@ -55,6 +56,14 @@ def get_dumpers() -> {str: dumper.Dumper}:
}


def output_version() -> bool:
python_version = '%d.%d.%d' % (sys.version_info[0], sys.version_info[1], sys.version_info[2])
print('Kosmorro %s' % VERSION)
print('Running on Python %s' % python_version)

return True


def clear_cache() -> bool:
confirm = input("Do you really want to clear Kosmorro's cache? [yN] ").upper()
if confirm == 'Y':
Expand All @@ -78,6 +87,8 @@ def get_args(output_formats: [str]):
' observer positioned at coordinates (0,0), with an altitude of 0.'
% today.strftime('%a %b %d, %Y'))

parser.add_argument('--version', '-v', dest='special_action', action='store_const', const=output_version,
default=None, help='Show the program version')
parser.add_argument('--clear-cache', dest='special_action', action='store_const', const=clear_cache, default=None,
help='Delete all the files Kosmorro stored in the cache.')
parser.add_argument('--format', '-f', type=str, default=output_formats[0], choices=output_formats,
Expand Down

0 comments on commit 5f74b08

Please sign in to comment.