Skip to content

Commit a6e751b

Browse files
committed
added flags to CLI to print version numbers and list available datasets
1 parent 0aa5314 commit a6e751b

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

coderdata/cli.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from typing import Union
55
import sys
66
from .download.downloader import download as download_datasets
7+
from .utils import version
8+
from .utils import list_datasets
79

810
def main():
911
parser = argparse.ArgumentParser(prog='coderdata')
@@ -37,12 +39,35 @@ def main():
3739
help='Allow dataset files to be overwritten if they already exist.'
3840
)
3941
parser_download.set_defaults(func=download)
42+
43+
grp = parser.add_mutually_exclusive_group()
44+
grp.add_argument(
45+
'-l', '--list',
46+
dest="LIST",
47+
action='store_true',
48+
help="Prints list of available datasets and exits program."
49+
)
50+
grp.add_argument(
51+
'-v', '--version',
52+
dest="VERSION",
53+
action='store_true',
54+
help="Prints the versions of the coderdata API and dataset and exits the program"
55+
)
56+
parser.set_defaults(func=info)
57+
4058
if len(sys.argv) == 1:
4159
parser.print_help(sys.stderr)
4260
sys.exit(0)
4361
args = parser.parse_args()
4462
args.func(args)
4563

64+
def info(args):
65+
if args.LIST:
66+
print(list_datasets())
67+
elif args.VERSION:
68+
print(version())
69+
70+
4671
def download(args):
4772
download_datasets(
4873
name=args.DATASET_NAME,

0 commit comments

Comments
 (0)