Skip to content

Commit

Permalink
Merge pull request #249 from wasi0013/v0.0.8
Browse files Browse the repository at this point in the history
V0.0.8
  • Loading branch information
wasi0013 authored Nov 1, 2023
2 parents 3c089af + 68e4d63 commit e602551
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 7 deletions.
19 changes: 18 additions & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,21 @@ History

* bug fix
* readme and doc update
* Improved Command line interface outputs.
* Improved Command line interface outputs.

0.0.7 (2023-11-01)
------------------

* Added show sub command for project.
* Added json sub command for project.
* refactored project and task commands output messages.
* fixed bugs in project sub commands.

0.0.8 (2023-11-01)
------------------

* Added config sub command.
* added command to save default user information.
* refactored project and task commands.
* fixed bugs.
* added config command to configure project meta data such as title, billable? etc.
2 changes: 1 addition & 1 deletion PyTM/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__author__ = "Wasi"
__email__ = "[email protected]"
__version__ = "0.0.7"
__version__ = "0.0.8"
61 changes: 57 additions & 4 deletions PyTM/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
from PyTM import __version__
import os
import datetime
from PyTM.core.data_handler import init_data, load_data
from PyTM.core.data_handler import init_data, load_data, save_data
from PyTM.settings import data_folder, data_filepath, state_filepath, CURRENT_PROJECT, CURRENT_TASK
from PyTM.console import console
from rich.table import Table
from rich.prompt import Prompt
from rich.prompt import Confirm
def greet():
"""
shows Greeting Texts
Expand Down Expand Up @@ -57,9 +59,9 @@ def cli():
@click.command()
def init():
"""
Initialize the pytm data store.
- initializes the pytm data store.
"""
console.print("[green on white]Initializing pytm-data.")
console.print("[green on white]Initializing pytm-data.\n")
try:
os.makedirs(data_folder)
console.print(f"Created data folder: {data_folder}")
Expand All @@ -77,11 +79,12 @@ def init():
init_data(state_filepath, {CURRENT_PROJECT: "", CURRENT_TASK: ""})
console.print(f"Created state file: {state_filepath}")
console.print("Done.")
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]")

@click.command()
def show():
"""
shows list of projects and status
- shows list of projects and status
"""
data = load_data()
table = Table()
Expand All @@ -92,10 +95,60 @@ def show():
table.add_row(key, f'{datetime.datetime.fromisoformat(value['created_at']).strftime("%Y, %B, %d, %H:%M:%S %p")}', value['status'])
console.print(table)

@click.group()
def config():
"""
- pytm sub-commands for configuration.
"""
...

@config.command()
def user():
"""
- config default user.
"""
state = load_data(state_filepath)
current_user = {}
if state.get("config"):
current_user = state.get("config").get("user", {})
else:
state['config'] = dict()
current_user["name"] = Prompt.ask("Name", default=current_user.get("name", ""))
current_user["email"] = Prompt.ask("Email", default=current_user.get("email", ""))
current_user["phone"] = Prompt.ask("Phone", default=current_user.get("phone", ""))
current_user["address"] = Prompt.ask("Address", default=current_user.get("address", ""))
current_user["website"] = Prompt.ask("Website", default=current_user.get("website", ""))
current_user["hourly_rate"] = Prompt.ask("Hourly rate in USD", default=current_user.get("hourly_rate", ""))
state['config']['user'] = current_user
save_data(state, state_filepath)
console.print("\n[green]Default user info updated.")

@config.command(name="project")
@click.argument("project_name")
def config_project(project_name):
"""
- config project meta data.
"""
data = load_data()
if data.get(project_name):
data[project_name]['meta'] = data.get(project_name).get("meta", {})
data[project_name]['meta']["title"] = Prompt.ask("Project Title", default=data[project_name]['meta'].get("title", ""))
data[project_name]['meta']["billable"] = Confirm.ask("Billable?", default=data[project_name]['meta'].get("billable", True))
data[project_name]['meta']["client_name"] = Prompt.ask("Client Name", default=data[project_name]['meta'].get("client_name", ""))
data[project_name]['meta']["client_email"] = Prompt.ask("Client Email", default=data[project_name]['meta'].get("client_email", ""))
data[project_name]['meta']["client_phone"] = Prompt.ask("Client Phone", default=data[project_name]['meta'].get("client_phone", ""))
data[project_name]['meta']["client_address"] = Prompt.ask("Client Address", default=data[project_name]['meta'].get("client_address", ""))
data[project_name]['meta']["client_website"] = Prompt.ask("Client Website", default=data[project_name]['meta'].get("client_website", ""))
else:
console.print(f"[bold red] Project {project_name} doesn't exist.")
save_data(data)
console.print("\n[green]Project Meta data updated.")

cli.add_command(init)
cli.add_command(project)
cli.add_command(task)
cli.add_command(show)
cli.add_command(config)

if __name__ == "__main__":
cli()
3 changes: 3 additions & 0 deletions PyTM/commands/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,14 @@ def start(project_name):
"""
- starts an existing project or creates a new project.
"""
data = load_data()
update(partial(create_project, project_name=project_name))
state = load_data(settings.state_filepath)
state[settings.CURRENT_PROJECT] = project_name
save_data(state, settings.state_filepath)
console.print(f"[bold blue]{project_name}[/bold blue] started.")
if project_name not in data.keys():
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]")


@project.command()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

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

0 comments on commit e602551

Please sign in to comment.