Skip to content

Commit e602551

Browse files
authored
Merge pull request #249 from wasi0013/v0.0.8
V0.0.8
2 parents 3c089af + 68e4d63 commit e602551

File tree

5 files changed

+80
-7
lines changed

5 files changed

+80
-7
lines changed

HISTORY.rst

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,21 @@ History
3838

3939
* bug fix
4040
* readme and doc update
41-
* Improved Command line interface outputs.
41+
* Improved Command line interface outputs.
42+
43+
0.0.7 (2023-11-01)
44+
------------------
45+
46+
* Added show sub command for project.
47+
* Added json sub command for project.
48+
* refactored project and task commands output messages.
49+
* fixed bugs in project sub commands.
50+
51+
0.0.8 (2023-11-01)
52+
------------------
53+
54+
* Added config sub command.
55+
* added command to save default user information.
56+
* refactored project and task commands.
57+
* fixed bugs.
58+
* added config command to configure project meta data such as title, billable? etc.

PyTM/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
__author__ = "Wasi"
22
__email__ = "[email protected]"
3-
__version__ = "0.0.7"
3+
__version__ = "0.0.8"

PyTM/cli.py

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
from PyTM import __version__
77
import os
88
import datetime
9-
from PyTM.core.data_handler import init_data, load_data
9+
from PyTM.core.data_handler import init_data, load_data, save_data
1010
from PyTM.settings import data_folder, data_filepath, state_filepath, CURRENT_PROJECT, CURRENT_TASK
1111
from PyTM.console import console
1212
from rich.table import Table
13+
from rich.prompt import Prompt
14+
from rich.prompt import Confirm
1315
def greet():
1416
"""
1517
shows Greeting Texts
@@ -57,9 +59,9 @@ def cli():
5759
@click.command()
5860
def init():
5961
"""
60-
Initialize the pytm data store.
62+
- initializes the pytm data store.
6163
"""
62-
console.print("[green on white]Initializing pytm-data.")
64+
console.print("[green on white]Initializing pytm-data.\n")
6365
try:
6466
os.makedirs(data_folder)
6567
console.print(f"Created data folder: {data_folder}")
@@ -77,11 +79,12 @@ def init():
7779
init_data(state_filepath, {CURRENT_PROJECT: "", CURRENT_TASK: ""})
7880
console.print(f"Created state file: {state_filepath}")
7981
console.print("Done.")
82+
console.print("\n[bold blue i on white]You also might want to run: `pytm config user` to configure default user data.[/bold blue i on white]")
8083

8184
@click.command()
8285
def show():
8386
"""
84-
shows list of projects and status
87+
- shows list of projects and status
8588
"""
8689
data = load_data()
8790
table = Table()
@@ -92,10 +95,60 @@ def show():
9295
table.add_row(key, f'{datetime.datetime.fromisoformat(value['created_at']).strftime("%Y, %B, %d, %H:%M:%S %p")}', value['status'])
9396
console.print(table)
9497

98+
@click.group()
99+
def config():
100+
"""
101+
- pytm sub-commands for configuration.
102+
"""
103+
...
104+
105+
@config.command()
106+
def user():
107+
"""
108+
- config default user.
109+
"""
110+
state = load_data(state_filepath)
111+
current_user = {}
112+
if state.get("config"):
113+
current_user = state.get("config").get("user", {})
114+
else:
115+
state['config'] = dict()
116+
current_user["name"] = Prompt.ask("Name", default=current_user.get("name", ""))
117+
current_user["email"] = Prompt.ask("Email", default=current_user.get("email", ""))
118+
current_user["phone"] = Prompt.ask("Phone", default=current_user.get("phone", ""))
119+
current_user["address"] = Prompt.ask("Address", default=current_user.get("address", ""))
120+
current_user["website"] = Prompt.ask("Website", default=current_user.get("website", ""))
121+
current_user["hourly_rate"] = Prompt.ask("Hourly rate in USD", default=current_user.get("hourly_rate", ""))
122+
state['config']['user'] = current_user
123+
save_data(state, state_filepath)
124+
console.print("\n[green]Default user info updated.")
125+
126+
@config.command(name="project")
127+
@click.argument("project_name")
128+
def config_project(project_name):
129+
"""
130+
- config project meta data.
131+
"""
132+
data = load_data()
133+
if data.get(project_name):
134+
data[project_name]['meta'] = data.get(project_name).get("meta", {})
135+
data[project_name]['meta']["title"] = Prompt.ask("Project Title", default=data[project_name]['meta'].get("title", ""))
136+
data[project_name]['meta']["billable"] = Confirm.ask("Billable?", default=data[project_name]['meta'].get("billable", True))
137+
data[project_name]['meta']["client_name"] = Prompt.ask("Client Name", default=data[project_name]['meta'].get("client_name", ""))
138+
data[project_name]['meta']["client_email"] = Prompt.ask("Client Email", default=data[project_name]['meta'].get("client_email", ""))
139+
data[project_name]['meta']["client_phone"] = Prompt.ask("Client Phone", default=data[project_name]['meta'].get("client_phone", ""))
140+
data[project_name]['meta']["client_address"] = Prompt.ask("Client Address", default=data[project_name]['meta'].get("client_address", ""))
141+
data[project_name]['meta']["client_website"] = Prompt.ask("Client Website", default=data[project_name]['meta'].get("client_website", ""))
142+
else:
143+
console.print(f"[bold red] Project {project_name} doesn't exist.")
144+
save_data(data)
145+
console.print("\n[green]Project Meta data updated.")
146+
95147
cli.add_command(init)
96148
cli.add_command(project)
97149
cli.add_command(task)
98150
cli.add_command(show)
151+
cli.add_command(config)
99152

100153
if __name__ == "__main__":
101154
cli()

PyTM/commands/project.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,14 @@ def start(project_name):
9393
"""
9494
- starts an existing project or creates a new project.
9595
"""
96+
data = load_data()
9697
update(partial(create_project, project_name=project_name))
9798
state = load_data(settings.state_filepath)
9899
state[settings.CURRENT_PROJECT] = project_name
99100
save_data(state, settings.state_filepath)
100101
console.print(f"[bold blue]{project_name}[/bold blue] started.")
102+
if project_name not in data.keys():
103+
console.print(f"\n[bold blue i on white]You also might want to run: `pytm config project {project_name}` to configure project meta data.[/bold blue i on white]")
101104

102105

103106
@project.command()

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
setup(
2525
name="python-pytm",
26-
version="0.0.7",
26+
version="0.0.8",
2727
description="PyTM - an Open Source Python Time Management Tool for Mankind",
2828
long_description=readme + "\n\n" + doclink + "\n\n" + history,
2929
long_description_content_type="text/x-rst",

0 commit comments

Comments
 (0)