13
13
CONTEXT_SETTINGS = dict (help_option_names = ["-h" , "--help" ])
14
14
15
15
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
+
16
45
@click .group (context_settings = CONTEXT_SETTINGS )
17
46
@click .option (
18
47
"-P" ,
19
48
"--profile-dir" ,
20
49
type = click .Path (file_okay = False , writable = True , path_type = Path ),
21
50
envvar = "QBPM_PROFILE_DIR" ,
51
+ show_envvar = True ,
22
52
default = default_profile_dir ,
23
- help = "directory in which profiles are stored " ,
53
+ help = "Defaults to $XDG_DATA_HOME/qutebrowser- profiles. " ,
24
54
)
25
55
@click .pass_context
26
56
def main (ctx : click .Context , profile_dir : Path ) -> None :
@@ -31,10 +61,7 @@ def main(ctx: click.Context, profile_dir: Path) -> None:
31
61
@main .command ()
32
62
@click .argument ("profile_name" )
33
63
@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
38
65
@click .pass_obj
39
66
def new (profile_dir : Path , profile_name : str , ** kwargs : Any ) -> None :
40
67
"""Create a new profile."""
@@ -45,10 +72,7 @@ def new(profile_dir: Path, profile_name: str, **kwargs: Any) -> None:
45
72
@main .command ()
46
73
@click .argument ("session" )
47
74
@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
52
76
@click .pass_obj
53
77
def from_session (
54
78
profile_dir : Path ,
@@ -78,8 +102,12 @@ def desktop(
78
102
79
103
@main .command ()
80
104
@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
+ )
83
111
@click .pass_obj
84
112
def launch (profile_dir : Path , profile_name : str , ** kwargs : Any ) -> None :
85
113
"""Launch qutebrowser with a specific profile."""
0 commit comments