Debian Codegraph @

src/harlequin_duckdb/cli_options.py

raw
1 from pathlib import Path
2
3 from harlequin.options import (
4 FlagOption,
5 ListOption,
6 PathOption,
7 TextOption,
8 )
9
10 init = PathOption(
11 name="init-path",
12 description=(
13 "The path to an initialization script. On startup, Harlequin will execute "
14 "the commands in the script against the attached database."
15 ),
16 short_decls=["-i", "-init"],
17 exists=False,
18 file_okay=True,
19 dir_okay=False,
20 resolve_path=True,
21 path_type=Path,
22 )
23
24 no_init = FlagOption(
25 name="no-init",
26 description="Start Harlequin without executing the initialization script.",
27 )
28
29 unsigned = FlagOption(
30 name="allow-unsigned-extensions",
31 description="Allow loading unsigned extensions",
32 short_decls=["-u", "-unsigned"],
33 )
34
35 extensions = ListOption(
36 name="extension",
37 description=(
38 "Install and load the named DuckDB extension when starting "
39 "Harlequin. To install multiple extensions, repeat this option."
40 ),
41 short_decls=["-e"],
42 )
43
44 force_extensions = FlagOption(
45 name="force-install-extensions",
46 description="Force install all extensions passed with -e.",
47 )
48
49 custom_extension_repo = TextOption(
50 name="custom-extension-repo",
51 description=(
52 "A value to pass to DuckDB's custom_extension_repository variable. "
53 "Will be set before installing any extensions that are passed using -e."
54 ),
55 )
56
57 md_token = TextOption(
58 name="md_token",
59 description=(
60 "MotherDuck Token. Pass your MotherDuck service token in this option, or "
61 "set the `motherduck_token` environment variable."
62 ),
63 # a service token, so nothing that reports on a profile may print it back,
64 # and the wizard must not echo it as it is typed
65 secret=True,
66 )
67
68 md_saas = FlagOption(
69 name="md_saas",
70 description="Run MotherDuck in SaaS mode (no local privileges).",
71 )
72
73 DUCKDB_OPTIONS = [
74 init,
75 no_init,
76 unsigned,
77 extensions,
78 force_extensions,
79 custom_extension_repo,
80 md_token,
81 md_saas,
82 ]