Skip to content

Commit

Permalink
Allow to start only projects in configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
lcfd committed Dec 10, 2023
1 parent 8415256 commit 7d319f5
Showing 1 changed file with 33 additions and 16 deletions.
49 changes: 33 additions & 16 deletions cli/trakcli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from trakcli.dev.commands import app as dev_app
from trakcli.initialize import initialize_trak
from trakcli.projects.commands import app as projects_app
from trakcli.projects.database import get_projects_from_config
from trakcli.report.commands.main import report
from trakcli.utils.print_with_padding import print_with_padding
from trakcli.create import app as create_app
Expand Down Expand Up @@ -133,27 +134,43 @@ def start_tracker(
project = typer.prompt("Which project do you want to track?")

record = tracking_already_started()
projects_in_config = get_projects_from_config()

if not record:
add_session(
Record(
project=project,
start=datetime.now().isoformat(),
billable=billable,
category=category,
tag=tag,
if project in projects_in_config:
add_session(
Record(
project=project,
start=datetime.now().isoformat(),
billable=billable,
category=category,
tag=tag,
)
)
)
rprint(
Panel.fit(
title="▶️ Start",
renderable=print_with_padding(
f"""[bold green]{project}[/bold green] started.
rprint(
Panel.fit(
title="▶️ Start",
renderable=print_with_padding(
f"""[bold green]{project}[/bold green] started.
Have a good session!"""
),
Have a good session!"""
),
)
)
)
else:
renderable_projects_list = "\n • ".join(projects_in_config)
rprint("")
rprint(
Panel(
title="[red]Missing project[/red]",
renderable=print_with_padding(
"This project doesn't exists.\n\n"
f"Awailable projects: \n{renderable_projects_list}\n\n\n\n"
"Try to run the `trak create project <project name>` command if you want to create a new project."
),
)
)
return
else:
formatted_start_time = datetime.fromisoformat(record["start"]).strftime(
"%m/%d/%Y, %H:%M"
Expand Down

0 comments on commit 7d319f5

Please sign in to comment.