Skip to content

Commit 1a68ed3

Browse files
committed
Adding CLI Capabilities
✨ CLI tool now exists to manage common lookup items Continuing to write tests, but CLI capabilities have been created. This will allow users to manage some of the data without having to work directly with the data store while the web frontend is being built. Working on #3
1 parent f613411 commit 1a68ed3

19 files changed

+674
-125
lines changed

Pipfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ coveralls="*"
1111

1212
[packages]
1313
boto3="*"
14+
Click="*"
1415
sqlalchemy="*"
1516
sqlalchemy-utils="*"
1617
python-dateutil="*"

Pipfile.lock

Lines changed: 12 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

process_tracker/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
from process_tracker.extract_tracker import ExtractTracker
22
from process_tracker.process_tracker import ProcessTracker
3+
4+
__version__ = '0.1.0'

process_tracker/actor.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

process_tracker/cli.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# ProcessTracker CLI Tool
2+
# A set of tools to set up ProcessTracker and maintain lookup topics
3+
4+
import click
5+
import logging
6+
7+
from process_tracker.data_store import DataStore
8+
9+
data_store = DataStore()
10+
logger = logging.getLogger('Process Tracker')
11+
12+
13+
@click.group()
14+
def main():
15+
"""
16+
This script provides methods for initializing ProcessTracker and managing lookup topics (i.e. Actor, Tool, etc.)
17+
:return:
18+
"""
19+
20+
21+
@main.command()
22+
def setup():
23+
"""
24+
Initialize ProcessTracker's data store with user provided input. If already in place, do nothing.
25+
:return:
26+
"""
27+
data_store.initialize_data_store()
28+
29+
30+
# @main.command()
31+
# def upgrade():
32+
# """
33+
# Upgrade ProcessTracker if data store on previous version.
34+
# :return:
35+
# """
36+
37+
38+
@main.command()
39+
@click.option('-t', '--topic', help='The topic being created')
40+
@click.option('-n', '--name', help='The name for the topic.')
41+
def create(topic, name):
42+
"""
43+
Create an item that is within the valid topics list.
44+
:param topic: The name of the topic.
45+
:type topic: string
46+
:param name: The name of the topic item to be added.
47+
:type name: string
48+
"""
49+
click.echo('Attempting to create %s with name %s' % (topic, name))
50+
data_store.topic_creator(topic=topic, name=name)
51+
52+
53+
@main.command()
54+
@click.option('-t', '--topic', help='The topic being created')
55+
@click.option('-n', '--name', help='The name for the topic.')
56+
def delete(topic, name):
57+
"""
58+
Delete an item that is within the valid topics list and not a pre-loaded item.
59+
:param topic: The name of the topic.
60+
:type topic: string
61+
:param name: The name of the topic item to be deleted.
62+
:type name: string
63+
"""
64+
click.echo('Attempting to delete %s with name %s' % (topic, name))
65+
data_store.topic_deleter(topic=topic, name=name)
66+
67+
68+
@main.command()
69+
@click.option('-t', '--topic', help='The topic being created')
70+
@click.option('-i', '--initial-name', help='The name that needs to be changed.')
71+
@click.option('-n', '--name', help='The new name for the topic.')
72+
def update(topic, initial_name, name):
73+
74+
topic = data_store.topic_validator(topic)
75+
76+
if topic:
77+
click.echo('Attempting to update %s with name %s to %s' % (topic, initial_name, name))
78+
item = data_store.get_item(topic=topic, name=initial_name)
79+
data_store.topic_updater(topic=topic, item=item, name=name)
80+
else:
81+
raise Exception('Invalid topic type.')

0 commit comments

Comments
 (0)