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

Add conan config show <conf> command #13354

Merged
merged 5 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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: 10 additions & 0 deletions conan/cli/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,13 @@ def config_list(conan_api, parser, subparser, *args):
"""
parser.parse_args(*args)
return BUILT_IN_CONFS


@conan_subcommand(formatters={"text": list_text_formatter, "json": default_json_formatter})
def config_get(conan_api, parser, subparser, *args):
"""
Get the value of the specified conf
"""
subparser.add_argument('conf', help='Conf item for which to query its value')
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved
args = parser.parse_args(*args)
return {args.conf: conan_api.config.get(args.conf)}
2 changes: 1 addition & 1 deletion conans/model/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ def __bool__(self):

def get(self, conf_name, default=None, check_type=None):
"""
Get the value of the conf name requested and convert it to the [type]-like passed.
Get the value of the conf name requested and convert it to the [type]-like passed.
"""
pattern, name = self._split_pattern_name(conf_name)
return self._pattern_confs.get(pattern, Conf()).get(name, default=default,
Expand Down
10 changes: 10 additions & 0 deletions conans/test/integration/command/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,13 @@ def _assert_config_not_exists(path):
_assert_config_exists("foo")

os.listdir(tc.current_folder)


def test_config_get():
globalconf = textwrap.dedent("""
tools.build:jobs=42
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved
""")
tc = TestClient()
tc.save_home({"global.conf": globalconf})
tc.run("config get tools.build:jobs")
assert "42" in tc.out