diff --git a/HISTORY.rst b/HISTORY.rst index 5653048..f95d908 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -38,4 +38,21 @@ History * bug fix * readme and doc update -* Improved Command line interface outputs. \ No newline at end of file +* 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. \ No newline at end of file diff --git a/PyTM/__init__.py b/PyTM/__init__.py index 4075f06..acb477b 100644 --- a/PyTM/__init__.py +++ b/PyTM/__init__.py @@ -1,3 +1,3 @@ __author__ = "Wasi" __email__ = "wasi0013@gmail.com" -__version__ = "0.0.7" +__version__ = "0.0.8" diff --git a/PyTM/cli.py b/PyTM/cli.py index e640e83..3c1edd3 100644 --- a/PyTM/cli.py +++ b/PyTM/cli.py @@ -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 @@ -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}") @@ -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() @@ -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() diff --git a/PyTM/commands/project.py b/PyTM/commands/project.py index 3566678..e065dec 100644 --- a/PyTM/commands/project.py +++ b/PyTM/commands/project.py @@ -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() diff --git a/setup.py b/setup.py index 1b7ff9e..bbd910f 100644 --- a/setup.py +++ b/setup.py @@ -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",