Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions aw_notify/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ def init_macos():
@click.pass_context
@click.option("-v", "--verbose", is_flag=True, help="Verbose logging.")
@click.option("--testing", is_flag=True, help="Enables testing mode.")
def main(ctx, verbose: bool, testing: bool):
@click.option("--port", type=int, default=None, help="Port to connect to ActivityWatch server.")
def main(ctx, verbose: bool, testing: bool, port: Optional[int]):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider updating the main() docstring/comment to mention the new 'port' option. Also, sharing common options (like testing and port) via a decorator could reduce duplication.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I agree with this, but I'll accept it.

setup_logging("aw-notify", testing=testing, verbose=verbose, log_file=True)
logging.getLogger("urllib3").setLevel(logging.WARNING)
logger.info("Starting...")
Expand All @@ -334,15 +335,17 @@ def main(ctx, verbose: bool, testing: bool):
init_macos()

if ctx.invoked_subcommand is None:
ctx.invoke(start, testing=testing)
ctx.invoke(start, testing=testing, port=port)


@main.command()
@click.option("--testing", is_flag=True, help="Enables testing mode.")
def start(testing=False):
@click.option("--port", type=int, default=None, help="Port to connect to ActivityWatch server.")
def start(testing=False, port=None):
"""Start the notification service."""
global aw, hostname
aw = aw_client.ActivityWatchClient("aw-notify", testing=testing)

aw = aw_client.ActivityWatchClient("aw-notify", testing=testing, port=port)
aw.wait_for_start()
hostname = aw.get_info().get("hostname", "unknown")

Expand Down