Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding version flag #31

Merged
merged 1 commit into from
Dec 20, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions repositorytools/cli/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,17 @@ def __init__(self):
help="Print lots of debugging information")
self.parser.add_argument("-Q", "--quiet", action="store_true", dest="quiet", default=False,
help="Print less information")
self.parser.add_argument("-V", "--version", action="store_true", dest="display_version", default=False,
help="Prints version and exit")
self.repository = None

def run(self, args=None):
args_namespace = self.parser.parse_args(args)
configure_logging(args_namespace.quiet, args_namespace.debug)
if args_namespace.display_version:
print('repositorytools v{}'.format(repositorytools.__version__))
self.parser.exit()
configure_logging(args_namespace.quiet, args_namespace.debug)
# in tests we don't use 'str(sys.argv), so we can log actual arguments
used_args = args or sys.argv[1:]
logger.info('Started %s, with arguments %s', sys.argv[0], str(used_args))
Expand Down