Skip to content

Commit

Permalink
cli: add --no-config argument
Browse files Browse the repository at this point in the history
This disables loading any default or custom config files.
Only arguments set directly will be parsed.
  • Loading branch information
bastimeyer authored and gravyboat committed Apr 27, 2023
1 parent 0744ee6 commit de18f4a
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/streamlink_cli/argparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,13 @@ def build_parser():
merged on top of each other where the last config has highest priority.
""",
)
general.add_argument(
"--no-config",
action="store_true",
help="""
Disable loading any default or custom config files.
""",
)
general.add_argument(
"-l", "--loglevel",
metavar="LEVEL",
Expand Down
3 changes: 3 additions & 0 deletions src/streamlink_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,9 @@ def setup_args(


def setup_config_args(parser, ignore_unknown=False):
if args.no_config:
return

config_files = []

if args.config:
Expand Down
48 changes: 48 additions & 0 deletions tests/cli/test_main_setup_config_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def resolve_url(name):
@pytest.mark.parametrize(("_args", "_config_files", "expected", "deprecations"), [
pytest.param(
{
"no_config": False,
"config": None,
"url": None,
},
Expand All @@ -63,6 +64,7 @@ def resolve_url(name):
),
pytest.param(
{
"no_config": False,
"config": [
str(configdir / "non-existent"),
],
Expand All @@ -78,6 +80,7 @@ def resolve_url(name):
),
pytest.param(
{
"no_config": False,
"config": None,
"url": "noplugin",
},
Expand All @@ -93,6 +96,7 @@ def resolve_url(name):
),
pytest.param(
{
"no_config": False,
"config": [
str(configdir / "non-existent"),
],
Expand All @@ -108,6 +112,7 @@ def resolve_url(name):
),
pytest.param(
{
"no_config": False,
"config": None,
"url": "testplugin",
},
Expand All @@ -124,6 +129,7 @@ def resolve_url(name):
),
pytest.param(
{
"no_config": False,
"config": None,
"url": "testplugin",
},
Expand Down Expand Up @@ -151,6 +157,7 @@ def resolve_url(name):
),
pytest.param(
{
"no_config": False,
"config": [
str(configdir / "custom"),
],
Expand All @@ -169,6 +176,7 @@ def resolve_url(name):
),
pytest.param(
{
"no_config": False,
"config": [
str(configdir / "custom"),
],
Expand All @@ -193,6 +201,7 @@ def resolve_url(name):
),
pytest.param(
{
"no_config": False,
"config": [
str(configdir / "non-existent"),
str(configdir / "primary"),
Expand All @@ -212,6 +221,45 @@ def resolve_url(name):
[],
id="Multiple custom configs",
),
pytest.param(
{
"no_config": True,
"config": [],
"url": "testplugin",
},
[],
[],
[],
id="No config",
),
pytest.param(
{
"no_config": True,
"config": [
str(configdir / "primary"),
str(configdir / "secondary"),
],
"url": "testplugin",
},
[],
[],
[],
id="No config with multiple custom configs",
),
pytest.param(
{
"no_config": True,
"config": [],
"url": "testplugin",
},
[
configdir / "primary",
DeprecatedPath(configdir / "secondary"),
],
[],
[],
id="No config with multiple default configs",
),
], indirect=["_args", "_config_files"])
def test_setup_config_args(
recwarn: pytest.WarningsRecorder,
Expand Down

0 comments on commit de18f4a

Please sign in to comment.