Skip to content

Commit

Permalink
Merge pull request #32 from lcfd/normalize-report
Browse files Browse the repository at this point in the history
Improve "report" command
  • Loading branch information
lcfd authored Dec 8, 2023
2 parents df9d441 + dcf78e7 commit 2e4436d
Show file tree
Hide file tree
Showing 13 changed files with 548 additions and 229 deletions.
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ You can install it with pip:
pip install trakcli
```

or with pipx:
or with `pipx`:

```bash
pipx install trakcli
Expand Down Expand Up @@ -69,40 +69,41 @@ pipx install ./dist/trakcli-x.x.x-py3-none-any.whl

to install `trak` usign the wheel file.


## Usage

The package has the useful `--help` command that will explain all the commands.

The CLI will guide you anyway through what you should and must do with messages with specific messages.
`trak --help`

The CLI will guide you through what you should and must do with messages with specific messages.

### Basic commands

```bash
# Start a new session
trak start <project-name>

# Stop the current session
trak stop

# Show the elapsed time of the current session
trak status

# Show the amount of hours spend on the project
trak report <project-name>
```

Start trakking a project that is billable:
Start tracking a billable project:

`trak start pasta -b`

Start tracking a project on a specific category/topic:

`trak start pasta -c rigatoni`

All the commands are described in the help command:

`trak --help`

## Starship

There is a dedicated command that ouputs clean strings for tools like Starship:
There is a dedicated command that outputs clean strings for tools like Starship:

`trak status -s` or `trak status --starship`

Expand All @@ -115,3 +116,5 @@ command = """ trak status -s """
when = "trak status"
shell = "sh"
```

This way you can stay updated on the state of your session wherever you integrate this command.
215 changes: 215 additions & 0 deletions cli/pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cli/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "trakcli"
version = "0.0.2"
version = "0.0.4"
description = "Keep a record of the time you dedicate to your projects."
authors = ["Luca Fedrizzi <[email protected]>"]
license = "AGPL-3.0"
Expand All @@ -22,7 +22,7 @@ trak = "trakcli.main:app"

[tool.poetry.dependencies]
python = "^3.11"
typer = {extras = ["all"], version = ">=0.9.0"}
typer = { extras = ["all"], version = ">=0.9.0" }


[tool.poetry.group.dev.dependencies]
Expand Down
5 changes: 0 additions & 5 deletions cli/trakcli/config/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from rich.panel import Panel

from trakcli.config.main import CONFIG_FILE_PATH, get_config
from trakcli.database.basic import get_json_file_content

app = typer.Typer()

Expand All @@ -23,7 +22,3 @@ def show():
renderable=JSON(json.dumps(CONFIG)),
)
)


if __name__ == "__main__":
app()
3 changes: 2 additions & 1 deletion cli/trakcli/config/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import json
from pathlib import Path

from trakcli.database.basic import get_json_file_content
from trakcli.utils.file_system.get_json_file_content import get_json_file_content


#
# Paths
Expand Down
13 changes: 7 additions & 6 deletions cli/trakcli/database/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@
from pathlib import Path
from rich import print as rprint

from trakcli.config.main import get_db_file_path
from trakcli.utils.file_system.get_json_file_content import get_json_file_content

def get_json_file_content(file_path: Path):
with open(file_path, "r") as db:
db_content = db.read()

return json.loads(db_content)
def get_db_content():
db_path = get_db_file_path()
return get_json_file_content(db_path)


def show_json_file_content(file_path: Path):
"""Show the content of a JSON file."""

with open(file_path, "r") as db:
db_content = db.read()
json_file_content = db.read()

parsed_json = json.loads(db_content)
parsed_json = json.loads(json_file_content)
rprint(parsed_json)


Expand Down
Loading

0 comments on commit 2e4436d

Please sign in to comment.