Skip to content
Merged
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
16 changes: 13 additions & 3 deletions knack/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ def get(self, section, option, fallback=_UNSET):
raise last_ex # pylint:disable=raising-bad-type
return fallback

def sections(self):
combined_sections = []
# Go through the config chain and combine all sections
for config in self._config_file_chain if self.use_local_config else self._config_file_chain[-1:]:
sections = config.sections()
for section in sections:
if section not in combined_sections:
combined_sections.append(section)
return combined_sections

def items(self, section):
import re
pattern = self.env_var_name(section, '.+')
Expand Down Expand Up @@ -174,6 +184,9 @@ def __init__(self, config_dir, config_path, config_comment=None):
def items(self, section):
return self.config_parser.items(section) if self.config_parser else []

def sections(self):
return self.config_parser.sections() if self.config_parser else []

def has_option(self, section, option):
return self.config_parser.has_option(section, option) if self.config_parser else False

Expand Down Expand Up @@ -234,6 +247,3 @@ def clear(self):
for section in self.config_parser.sections():
self.config_parser.remove_section(section)
self.set(self.config_parser)

def sections(self):
return self.config_parser.sections()