You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Config-file.md
+8-1Lines changed: 8 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,18 @@
1
1
# Config file
2
2
Any settings you see in the `--help` command can be modified via a YAML config file.
3
3
4
-
By default, we try to find one in the current working dir, whose name stem is the same as the program's. Ex: program.py will search for program.yaml. This behaviour can be changed via the [run][mininterface.run] method.
4
+
By default, we try to find one in the current working dir, whose name stem is the same as the program's. Ex: program.py will search for program.yaml. This behaviour can be changed via the [run][mininterface.run] method`config_file` or `add_config` parameters or via `MININTERFACE_CONFIG` environment variable.
5
5
6
6
!!! Tip
7
7
You do not have to re-define all the settings in the config file, you can choose a few.
8
8
9
+
## Search order by highest priority
10
+
11
+
*`$ program.py --config PATH` with `run(add_config=True)` will load `PATH`
12
+
*`$ MININTERFACE_CONFIG=PATH program.py` will load `PATH`
13
+
*`$ program.py` with `run(config_file=PATH)` will load `PATH`
14
+
*`$ program.py` with `run(config_file=True)` will load `program.yaml`
Copy file name to clipboardExpand all lines: mininterface/_lib/run.py
+30-11Lines changed: 30 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,7 @@ def run(
32
32
title: str="",
33
33
config_file: Path|str|bool=True,
34
34
*,
35
+
add_config: bool=False,
35
36
add_help: bool=True,
36
37
add_verbose: bool|int|Sequence[int] =True,
37
38
add_version: Optional[str] =None,
@@ -83,9 +84,13 @@ class Env:
83
84
whose name stem is the same as the program's.
84
85
Ex: `program.py` will search for `program.yaml`.
85
86
If False, no config file is used.
87
+
88
+
Might be superseded by `add_config` or `MININTERFACE_CONFIG` environment variable.
89
+
86
90
See the [Config file](Config-file.md) section.
87
-
add_help: Adds the help flag.
88
-
add_verbose: The default base Python verbosity logging level is `logging.WARNING`. Here you can add the verbose flag that automatically increases the level to `logging.INFO` (*-v*) or `logging.DEBUG` (*-vv*).
91
+
add_config: Adds the `--config` flag to change the config file location.
92
+
add_help: Adds the `--help` flag.
93
+
add_verbose: Adds the `--verbose` flag. The default base Python verbosity logging level is `logging.WARNING`. Here you can add the verbose flag that automatically increases the level to `logging.INFO` (*-v*) or `logging.DEBUG` (*-vv*).
89
94
Either, the value is `True` (the default) which means the base logging level stays at `logging.WARNING` and the flag is added. `False` means no flag is added.
90
95
Also, it can be `int` to determine the default logging state (i.g. some programs prefer to show INFO by default) or a sequnce of `int`s for even finer control.
91
96
@@ -140,7 +145,7 @@ class Env:
140
145
141
146
When user writes more `-v` than defined, the level sets to `logging.NOTSET`.
142
147
143
-
add_version: Your program version. Adds the version flag.
148
+
add_version: Adds the `--version` flag to print out your program's version.
0 commit comments