Skip to content
New issue

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

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

Already on GitHub? # to your account

Add --version option #45

Merged
merged 1 commit into from
Mar 24, 2022
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
3 changes: 3 additions & 0 deletions git_crecord/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# SPDX-License-Identifier: GPL-2.0-or-later

import argparse
import importlib.metadata
import os
import sys
import tempfile
Expand Down Expand Up @@ -179,6 +180,7 @@ def commit(self, *files, **opts):

def main():
prog = os.path.basename(sys.argv[0]).replace('-', ' ')
version = importlib.metadata.version("git-crecord")

subcommand = prog.split(' ')[-1].replace('.py', '')

Expand Down Expand Up @@ -212,6 +214,7 @@ def main():
parser.add_argument('--quiet', default=False, action='store_true', help='pass --quiet to git commit')
parser.add_argument('--confirm', default=False, action='store_true',
help='show confirmation prompt after selecting changes')
parser.add_argument('--version', action='version', version=f'%(prog)s {version}')
group = parser.add_mutually_exclusive_group()
group.add_argument('--cached', '--staged', action='store_true', default=False, help=argparse.SUPPRESS)
group.add_argument('--index', action='store_true', default=False, help=argparse.SUPPRESS)
Expand Down