Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/config list pattern #17000

Merged
merged 2 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions conan/cli/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,14 @@ def config_list(conan_api, parser, subparser, *args):
"""
Show all the Conan available configurations: core and tools.
"""
parser.parse_args(*args)
return conan_api.config.builtin_confs
subparser.add_argument('pattern', nargs="?",
help="Filter configuration items that matches this pattern")
args = parser.parse_args(*args)
confs = conan_api.config.builtin_confs
if args.pattern:
p = args.pattern.lower()
confs = {k: v for k, v in confs.items() if p in k.lower() or p in v.lower()}
return confs


@conan_subcommand(formatters={"text": list_text_formatter, "json": default_json_formatter})
Expand Down
7 changes: 5 additions & 2 deletions test/integration/command/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ def test_config_list():
client.run("config list --format=json")
assert f"{json.dumps(BUILT_IN_CONFS, indent=4)}\n" == client.stdout

client.run("config list unexpectedarg", assert_error=True)
assert "unrecognized arguments: unexpectedarg" in client.out
client.run("config list cmake")
assert "tools.cmake:cmake_program: Path to CMake executable" in client.out
assert "core.download:parallel" not in client.out
assert "tools.build:verbosity" not in client.out


def test_config_install():
Expand Down Expand Up @@ -85,6 +87,7 @@ def test_config_install_conanignore():
'config_folder/tests/tester': '',
'config_folder/other_tests/tester2': ''
})

def _assert_config_exists(path):
assert os.path.exists(os.path.join(tc.cache_folder, path))

Expand Down