Skip to content

Commit

Permalink
chore: make the --dev flag also set verbose logging
Browse files Browse the repository at this point in the history
  • Loading branch information
friday committed Apr 28, 2024
1 parent cf5b23c commit 2c79548
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ run: prefs # Run ulauncher from source
systemctl --user stop ulauncher || true
fi
killall -eq ulauncher || true
./bin/ulauncher -v --dev
./bin/ulauncher --dev

run-container: # Start a bash session in the Ulauncher Docker build container (Ubuntu)
@set -euo pipefail
Expand Down
28 changes: 25 additions & 3 deletions ulauncher/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import argparse
import os
from dataclasses import dataclass
from functools import lru_cache
from gettext import gettext

Expand All @@ -14,6 +15,7 @@
FIRST_RUN = not os.path.exists(PATHS.CONFIG) # If there is no config dir, assume it's the first run
FIRST_V6_RUN = not os.path.exists(PATHS.STATE)


if not os.path.exists(PATHS.ASSETS):
raise OSError(PATHS.ASSETS)

Expand All @@ -24,8 +26,18 @@
os.makedirs(PATHS.USER_THEMES, exist_ok=True)


@dataclass
class Arguments:
dev: bool
verbose: bool
no_window: bool
no_window_shadow: bool
hide_window: bool
no_extensions: bool


@lru_cache(maxsize=None)
def get_options() -> argparse.Namespace:
def get_options() -> Arguments:
"""Command Line options for the initial ulauncher (daemon) call"""
# Python's argparse is very similar to Gtk.Application.add_main_option_entries,
# but GTK adds in their own options we don't want like --help-gtk --help-gapplication --help-all
Expand All @@ -42,9 +54,19 @@ def get_options() -> argparse.Namespace:
"--version", action="version", help=gettext("Show version number and exit"), version=f"Ulauncher {VERSION}"
)
parser.add_argument("--no-window", action="store_true", help=gettext("Hide window upon application startup"))
parser.add_argument("--dev", action="store_true", help=gettext("Enables context menu in the Preferences UI"))
parser.add_argument(
"--dev",
action="store_true",
help=gettext("Developer mode (enables verbose logging and Preferences UI context menu)"),
)

# deprecated
parser.add_argument("--no-extensions", action="store_true", help=argparse.SUPPRESS)
parser.add_argument("--no-window-shadow", action="store_true", help=argparse.SUPPRESS)
parser.add_argument("--hide-window", action="store_true", help=argparse.SUPPRESS)

return parser.parse_args()
args = Arguments(**vars(parser.parse_args()))
if args.dev:
args.verbose = True

return args

0 comments on commit 2c79548

Please sign in to comment.