qutebrowser profile manager
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

replace kwargs with explicit arguments

+68 -27
+1 -1
src/qbpm/launch.py
··· 7 7 8 8 9 9 def launch_qutebrowser( 10 - profile: Profile | None, foreground: bool, qb_args: tuple[str, ...] 10 + profile: Profile | None, foreground: bool, qb_args: tuple[str, ...] = () 11 11 ) -> bool: 12 12 qb = profile.cmdline() if profile else [qutebrowser_exe()] 13 13 return launch(foreground, [*qb, *qb_args])
+67 -26
src/qbpm/main.py
··· 2 2 import sys 3 3 from collections.abc import Callable 4 4 from dataclasses import dataclass 5 + from functools import wraps 5 6 from pathlib import Path 6 7 from typing import Any, NoReturn 7 8 ··· 22 23 profile_dir: Path 23 24 24 25 25 - def creator_options(f: Callable[..., Any]) -> Callable[..., Any]: 26 + @dataclass 27 + class CreatorOptions: 28 + qb_config_dir: Path | None 29 + launch: bool 30 + foreground: bool 31 + desktop_file: bool 32 + overwrite: bool 33 + 34 + 35 + def creator_options(orig: Callable[..., Any]) -> Callable[..., Any]: 36 + @wraps(orig) 37 + def command( 38 + qb_config_dir: Path | None, 39 + launch: bool, 40 + foreground: bool, 41 + desktop_file: bool, 42 + overwrite: bool, 43 + *args: Any, 44 + **kwargs: Any, 45 + ) -> Any: 46 + return orig( 47 + *args, 48 + c_opts=CreatorOptions( 49 + qb_config_dir, launch, foreground, desktop_file, overwrite 50 + ), 51 + **kwargs, 52 + ) 53 + 26 54 for opt in reversed( 27 55 [ 28 56 click.option( ··· 54 82 ), 55 83 ] 56 84 ): 57 - f = opt(f) 58 - return f 85 + command = opt(command) 86 + return command 59 87 60 88 61 89 class LowerCaseFormatter(logging.Formatter): ··· 96 124 @click.argument("home_page", required=False) 97 125 @creator_options 98 126 @click.pass_obj 99 - def new(context: Context, profile_name: str, **kwargs: Any) -> None: 127 + def new( 128 + context: Context, 129 + profile_name: str, 130 + home_page: str | None, 131 + c_opts: CreatorOptions, 132 + ) -> None: 100 133 """Create a new profile.""" 101 134 profile = Profile(profile_name, **vars(context)) 102 - then_launch(profiles.new_profile, profile, **kwargs) 135 + exit_with( 136 + profiles.new_profile( 137 + profile, 138 + c_opts.qb_config_dir, 139 + home_page, 140 + c_opts.desktop_file, 141 + c_opts.overwrite, 142 + ) 143 + and ((not c_opts.launch) or launch_qutebrowser(profile, c_opts.foreground)) 144 + ) 103 145 104 146 105 147 @main.command() ··· 111 153 context: Context, 112 154 session: str, 113 155 profile_name: str | None, 114 - **kwargs: Any, 156 + c_opts: CreatorOptions, 115 157 ) -> None: 116 158 """Create a new profile from a saved qutebrowser session. 117 159 SESSION may be the name of a session in the global qutebrowser profile 118 160 or a path to a session yaml file. 119 161 """ 120 162 profile, session_path = session_info(session, profile_name, context) 121 - then_launch(operations.from_session, profile, session_path=session_path, **kwargs) 163 + exit_with( 164 + operations.from_session( 165 + profile, 166 + session_path, 167 + c_opts.qb_config_dir, 168 + c_opts.desktop_file, 169 + c_opts.overwrite, 170 + ) 171 + and ((not c_opts.launch) or launch_qutebrowser(profile, c_opts.foreground)) 172 + ) 122 173 123 174 124 - @main.command(context_settings={"ignore_unknown_options": True}) 175 + @main.command("launch", context_settings={"ignore_unknown_options": True}) 125 176 @click.argument("profile_name") 126 177 @click.argument("qb_args", nargs=-1, type=click.UNPROCESSED) 127 178 @click.option( 128 179 "-f", "--foreground", is_flag=True, help="Run qutebrowser in the foreground." 129 180 ) 130 181 @click.pass_obj 131 - def launch(context: Context, profile_name: str, **kwargs: Any) -> None: 182 + def launch_profile( 183 + context: Context, profile_name: str, foreground: bool, qb_args: tuple[str, ...] 184 + ) -> None: 132 185 """Launch qutebrowser with a specific profile. All QB_ARGS are passed on to qutebrowser.""" 133 186 profile = Profile(profile_name, **vars(context)) 134 - exit_with(launch_qutebrowser(profile, **kwargs)) 187 + exit_with(launch_qutebrowser(profile, foreground, qb_args)) 135 188 136 189 137 190 @main.command(context_settings={"ignore_unknown_options": True}) ··· 147 200 "-f", "--foreground", is_flag=True, help="Run qutebrowser in the foreground." 148 201 ) 149 202 @click.pass_obj 150 - def choose(context: Context, **kwargs: Any) -> None: 203 + def choose( 204 + context: Context, menu: str | None, foreground: bool, qb_args: tuple[str, ...] 205 + ) -> None: 151 206 """Choose a profile to launch. 152 207 Support is built in for many X and Wayland launchers, as well as applescript dialogs. 153 208 All QB_ARGS are passed on to qutebrowser. 154 209 """ 155 - exit_with(choose_profile(profile_dir=context.profile_dir, **kwargs)) 210 + exit_with(choose_profile(context.profile_dir, menu, foreground, qb_args)) 156 211 157 212 158 213 @main.command() ··· 185 240 """Create an XDG desktop entry for an existing profile.""" 186 241 profile = Profile(profile_name, **vars(context)) 187 242 exit_with(operations.desktop(profile)) 188 - 189 - 190 - def then_launch( 191 - operation: Callable[..., bool], 192 - profile: Profile, 193 - launch: bool, 194 - foreground: bool, 195 - qb_args: tuple[str, ...] = (), 196 - **kwargs: Any, 197 - ) -> None: 198 - exit_with( 199 - operation(profile, **kwargs) 200 - and ((not launch) or launch_qutebrowser(profile, foreground, qb_args)) 201 - ) 202 243 203 244 204 245 def session_info(