mirror of https://github.com/dbcli/pgcli
Casing for column headers (based on casing file)
``` koljonen@localhost:koljonen> SELECT transferid, parenttransferid, amount from transfers ╒══════════════╤════════════════════╤══════════╕ │ TransferID │ ParentTransferID │ Amount │ ╞══════════════╪════════════════════╪══════════╡ ... ... ... ```
This commit is contained in:
parent
9a8d2c2d6f
commit
49ba6b4001
|
@ -4,6 +4,7 @@ Upcoming
|
|||
Features:
|
||||
---------
|
||||
* Suggest objects from all schemas (not just those in search_path) (Thanks: `Joakim Koljonen`_)
|
||||
* Casing for column headers (Thanks: `Joakim Koljonen`_)
|
||||
|
||||
1.5.1
|
||||
=====
|
||||
|
|
|
@ -77,10 +77,10 @@ MetaQuery.__new__.__defaults__ = ('', False, 0, False, False, False, False)
|
|||
|
||||
OutputSettings = namedtuple(
|
||||
'OutputSettings',
|
||||
'table_format dcmlfmt floatfmt missingval expanded max_width'
|
||||
'table_format dcmlfmt floatfmt missingval expanded max_width case_function'
|
||||
)
|
||||
OutputSettings.__new__.__defaults__ = (
|
||||
None, None, None, '<null>', False, None
|
||||
None, None, None, '<null>', False, None, lambda x: x
|
||||
)
|
||||
|
||||
# no-op logging handler
|
||||
|
@ -164,6 +164,7 @@ class PGCli(object):
|
|||
'generate_aliases': c['main'].as_bool('generate_aliases'),
|
||||
'asterisk_column_order': c['main']['asterisk_column_order'],
|
||||
'qualify_columns': c['main']['qualify_columns'],
|
||||
'case_column_headers': c['main'].as_bool('case_column_headers'),
|
||||
'search_path_filter': c['main'].as_bool('search_path_filter'),
|
||||
'single_connection': single_connection,
|
||||
'less_chatty': less_chatty,
|
||||
|
@ -610,7 +611,11 @@ class PGCli(object):
|
|||
floatfmt=self.float_format,
|
||||
missingval=self.null_string,
|
||||
expanded=expanded,
|
||||
max_width=max_width
|
||||
max_width=max_width,
|
||||
case_function=(
|
||||
self.completer.case if self.settings['case_column_headers']
|
||||
else lambda x: x
|
||||
)
|
||||
)
|
||||
formatted = format_output(title, cur, headers, status, settings)
|
||||
|
||||
|
@ -831,10 +836,11 @@ def format_output(title, cur, headers, status, settings):
|
|||
floatfmt = settings.floatfmt
|
||||
expanded = settings.expanded
|
||||
max_width = settings.max_width
|
||||
case_function = settings.case_function
|
||||
if title: # Only print the title if it's not None.
|
||||
output.append(title)
|
||||
if cur:
|
||||
headers = [utf8tounicode(x) for x in headers]
|
||||
headers = [case_function(utf8tounicode(x)) for x in headers]
|
||||
if expanded and headers:
|
||||
output.append(expanded_table(cur, headers, missingval))
|
||||
else:
|
||||
|
|
|
@ -50,6 +50,9 @@ casing_file = default
|
|||
# location, one will be generated based on usage in SQL/PLPGSQL functions.
|
||||
generate_casing_file = False
|
||||
|
||||
# Casing of column headers based on the casing_file described above
|
||||
case_column_headers = True
|
||||
|
||||
# history_file location.
|
||||
# In Unix/Linux: ~/.config/pgcli/history
|
||||
# In Windows: %USERPROFILE%\AppData\Local\dbcli\pgcli\history
|
||||
|
|
Loading…
Reference in New Issue