-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from lcfd/development-mode
Development mode
- Loading branch information
Showing
14 changed files
with
423 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
__app_name__ = "trak" | ||
__version__ = "0.0.2" | ||
__website__ = "https://usetrak.com" | ||
__git_repository__ = "https://github.com/lcfd/trak" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
from trakcli import __app_name__ | ||
|
||
from trakcli.main import app | ||
|
||
app(prog_name=__app_name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import typer | ||
from rich import print as rprint | ||
from rich.align import Align | ||
from rich.panel import Panel | ||
|
||
from trakcli.__init__ import __app_name__, __git_repository__, __version__, __website__ | ||
|
||
|
||
def version_callback(value: bool) -> None: | ||
""" | ||
Print the application version. | ||
""" | ||
if value: | ||
rprint( | ||
Panel( | ||
renderable=Align.center(f"{__app_name__} v{__version__}"), | ||
title=__app_name__, | ||
padding=(2), | ||
), | ||
) | ||
raise typer.Exit() | ||
|
||
|
||
def website_callback(value: bool) -> None: | ||
""" | ||
Launch the usetrak.com website. | ||
""" | ||
if value: | ||
typer.launch(__website__) | ||
raise typer.Exit() | ||
|
||
|
||
def repository_callback(value: bool) -> None: | ||
""" | ||
Launch the usetrak.com website. | ||
""" | ||
if value: | ||
typer.launch(__git_repository__) | ||
raise typer.Exit() | ||
|
||
|
||
def issues_callback(value: bool) -> None: | ||
""" | ||
Launch issues page. | ||
""" | ||
if value: | ||
typer.launch("https://github.com/lcfd/trak/issues") | ||
raise typer.Exit() | ||
|
||
|
||
def report_bug_callback(value: bool) -> None: | ||
""" | ||
Launch report bug page. | ||
""" | ||
if value: | ||
typer.launch("https://github.com/lcfd/trak/issues/new") | ||
raise typer.Exit() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import json | ||
|
||
import typer | ||
from rich import print as rprint | ||
from rich.json import JSON | ||
from rich.panel import Panel | ||
|
||
from trakcli.config.main import CONFIG_FILE_PATH | ||
from trakcli.database.basic import get_json_file_content | ||
|
||
app = typer.Typer() | ||
|
||
|
||
@app.command() | ||
def show(): | ||
"""Show the config file.""" | ||
|
||
rprint( | ||
Panel( | ||
title=f"Your config file {CONFIG_FILE_PATH}", | ||
renderable=JSON(json.dumps(get_json_file_content(CONFIG_FILE_PATH))), | ||
) | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
app() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import json | ||
from pathlib import Path | ||
from rich import print as rprint | ||
|
||
|
||
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 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() | ||
|
||
parsed_json = json.loads(db_content) | ||
rprint(parsed_json) | ||
|
||
|
||
def manage_field_in_json_file( | ||
file_path: Path, field_name: str, field_value: str | int | float | bool | ||
): | ||
"""Manage the content of a single object JSON file.""" | ||
|
||
with open(file_path, "r") as db: | ||
db_content = db.read() | ||
|
||
parsed_json = json.loads(db_content) | ||
if field_name: | ||
parsed_json[field_name] = field_value | ||
|
||
with open(file_path, "w") as db: | ||
json.dump(parsed_json, db, indent=2, separators=(",", ": ")) | ||
|
||
|
||
def overwrite_json_file(file_path: Path, content: dict | list[dict]): | ||
"""Fill a JSON file with the provided content. It's a complete overwrite.""" | ||
|
||
with open(file_path, "w") as db: | ||
json.dump(content, db, indent=2, separators=(",", ": ")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from typing import NamedTuple | ||
|
||
|
||
class Record(NamedTuple): | ||
project: str = "" | ||
start: str = "" | ||
end: str = "" | ||
billable: bool = False | ||
category: str = "" | ||
tag: str = "" | ||
|
||
|
||
# SPOILER | ||
|
||
# class Project(NamedTuple): | ||
# short_name: str | ||
# name: str = "" | ||
# description: str = "" | ||
# customer: str = "" | ||
# hour_rate: str = "" |
Empty file.
Oops, something went wrong.