1313CONTEXT_SETTINGS = dict (help_option_names = ["-h" , "--help" ])
1414
1515
16+ def creator_options (f : Callable [..., Any ]) -> Callable [..., Any ]:
17+ for opt in reversed (
18+ [
19+ click .option ("-l" , "--launch" , is_flag = True , help = "Launch the profile." ),
20+ click .option (
21+ "-f" ,
22+ "--foreground" ,
23+ is_flag = True ,
24+ help = "If --launch is set, run qutebrowser in the foreground." ,
25+ ),
26+ click .option (
27+ "--no-desktop-file" ,
28+ "desktop_file" ,
29+ default = True ,
30+ is_flag = True ,
31+ flag_value = False ,
32+ help = "Do not generate a .desktop file for the profile." ,
33+ ),
34+ click .option (
35+ "--overwrite" ,
36+ is_flag = True ,
37+ help = "Replace the current profile configuration if it exists." ,
38+ ),
39+ ]
40+ ):
41+ f = opt (f )
42+ return f
43+
44+
1645@click .group (context_settings = CONTEXT_SETTINGS )
1746@click .option (
1847 "-P" ,
1948 "--profile-dir" ,
2049 type = click .Path (file_okay = False , writable = True , path_type = Path ),
2150 envvar = "QBPM_PROFILE_DIR" ,
51+ show_envvar = True ,
2252 default = default_profile_dir ,
23- help = "directory in which profiles are stored " ,
53+ help = "Defaults to $XDG_DATA_HOME/qutebrowser- profiles. " ,
2454)
2555@click .pass_context
2656def main (ctx : click .Context , profile_dir : Path ) -> None :
@@ -31,10 +61,7 @@ def main(ctx: click.Context, profile_dir: Path) -> None:
3161@main .command ()
3262@click .argument ("profile_name" )
3363@click .argument ("home_page" , required = False )
34- @click .option ("--desktop-file/--no-desktop-file" , default = True , is_flag = True )
35- @click .option ("--overwrite" , is_flag = True )
36- @click .option ("-l" , "--launch" , is_flag = True )
37- @click .option ("-f" , "--foreground" , is_flag = True )
64+ @creator_options
3865@click .pass_obj
3966def new (profile_dir : Path , profile_name : str , ** kwargs : Any ) -> None :
4067 """Create a new profile."""
@@ -45,10 +72,7 @@ def new(profile_dir: Path, profile_name: str, **kwargs: Any) -> None:
4572@main .command ()
4673@click .argument ("session" )
4774@click .argument ("profile_name" , required = False )
48- @click .option ("--desktop-file/--no-desktop-file" , default = True , is_flag = True )
49- @click .option ("--overwrite" , is_flag = True )
50- @click .option ("-l" , "--launch" , is_flag = True )
51- @click .option ("-f" , "--foreground" , is_flag = True )
75+ @creator_options
5276@click .pass_obj
5377def from_session (
5478 profile_dir : Path ,
@@ -78,8 +102,12 @@ def desktop(
78102
79103@main .command ()
80104@click .argument ("profile_name" )
81- @click .option ("-c" , "--create" , is_flag = True )
82- @click .option ("-f" , "--foreground" , is_flag = True )
105+ @click .option (
106+ "-f" , "--foreground" , is_flag = True , help = "Run qutebrowser in the foreground."
107+ )
108+ @click .option (
109+ "-c" , "--create" , is_flag = True , help = "Create the profile if it does not exist."
110+ )
83111@click .pass_obj
84112def launch (profile_dir : Path , profile_name : str , ** kwargs : Any ) -> None :
85113 """Launch qutebrowser with a specific profile."""
0 commit comments