Skip to content

Commit b82a7c7

Browse files
committed
passthrough args for launch and choose
1 parent 4cf4d9d commit b82a7c7

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

qbpm/main.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,9 @@ def desktop(
100100
exit_with(operations.desktop(profile))
101101

102102

103-
@main.command()
103+
@main.command(context_settings=dict(ignore_unknown_options=True))
104104
@click.argument("profile_name")
105+
@click.argument("qb_args", nargs=-1, type=click.UNPROCESSED)
105106
@click.option(
106107
"-f", "--foreground", is_flag=True, help="Run qutebrowser in the foreground."
107108
)
@@ -110,13 +111,13 @@ def desktop(
110111
)
111112
@click.pass_obj
112113
def launch(profile_dir: Path, profile_name: str, **kwargs: Any) -> None:
113-
"""Launch qutebrowser with a specific profile."""
114+
"""Launch qutebrowser with a specific profile. All QB_ARGS are passed on to qutebrowser."""
114115
profile = Profile(profile_name, profile_dir)
115-
# TODO qb args
116-
exit_with(operations.launch(profile, qb_args=[], **kwargs))
116+
exit_with(operations.launch(profile, **kwargs))
117117

118118

119-
@main.command()
119+
@main.command(context_settings=dict(ignore_unknown_options=True))
120+
@click.argument("qb_args", nargs=-1, type=click.UNPROCESSED)
120121
@click.option(
121122
"-m",
122123
"--menu",
@@ -128,9 +129,9 @@ def launch(profile_dir: Path, profile_name: str, **kwargs: Any) -> None:
128129
def choose(profile_dir: Path, **kwargs: Any) -> None:
129130
"""Choose a profile to launch.
130131
Support is built in for many X and Wayland launchers, as well as applescript dialogs.
132+
All QB_ARGS are passed on to qutebrowser."
131133
"""
132-
# TODO qb args
133-
exit_with(operations.choose(profile_dir=profile_dir, qb_args=[], **kwargs))
134+
exit_with(operations.choose(profile_dir=profile_dir, **kwargs))
134135

135136

136137
@main.command()
@@ -158,7 +159,7 @@ def then_launch(
158159
profile: Profile,
159160
launch: bool,
160161
foreground: bool,
161-
qb_args: list[str] = [],
162+
qb_args: tuple[str, ...],
162163
**kwargs: Any,
163164
) -> None:
164165
exit_with(

qbpm/operations.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ def from_session(
2929

3030

3131
def launch(
32-
profile: Profile, create: bool, foreground: bool, qb_args: list[str]
32+
profile: Profile, create: bool, foreground: bool, qb_args: tuple[str, ...]
3333
) -> bool:
3434
if not profiles.ensure_profile_exists(profile, create):
3535
return False
3636

37-
args = profile.cmdline() + qb_args
37+
args = profile.cmdline() + list(qb_args)
3838
if not shutil.which(args[0]):
3939
error("qutebrowser is not installed")
4040
return False
@@ -65,7 +65,9 @@ def desktop(profile: Profile) -> bool:
6565
return exists
6666

6767

68-
def choose(profile_dir: Path, menu: str, foreground: bool, qb_args: list[str]) -> bool:
68+
def choose(
69+
profile_dir: Path, menu: str, foreground: bool, qb_args: tuple[str, ...]
70+
) -> bool:
6971
menu = menu or next(installed_menus())
7072
if not menu:
7173
error(f"No menu program found, please install one of: {AUTO_MENUS}")
@@ -100,7 +102,9 @@ def choose(profile_dir: Path, menu: str, foreground: bool, qb_args: list[str]) -
100102
return True
101103

102104

103-
def menu_command(menu: str, profiles: list[str], qb_args: list[str]) -> Optional[str]:
105+
def menu_command(
106+
menu: str, profiles: list[str], qb_args: tuple[str, ...]
107+
) -> Optional[str]:
104108
arg_string = " ".join(qb_args)
105109
if menu == "applescript":
106110
profile_list = '", "'.join(profiles)

0 commit comments

Comments
 (0)