Skip to content

Commit a0d9de6

Browse files
author
Hugo Osvaldo Barrera
authored
Merge pull request #247 from pimutils/porcelain-precedence
Make --porcelain take precedence over config
2 parents 342be9f + 9ab7d01 commit a0d9de6

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

tests/test_cli.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,3 +883,15 @@ def test_priority(runner):
883883
])
884884

885885
assert '!!!' in result.output
886+
887+
888+
def test_porcelain_precedence(runner, tmpdir):
889+
"""Test that --humanize flag takes precedence over `porcelain` config"""
890+
891+
path = tmpdir.join('config')
892+
path.write('humanize = true\n', 'a')
893+
894+
with patch('todoman.formatters.PorcelainFormatter') as mocked_formatter:
895+
runner.invoke(cli, ['--porcelain', 'list'])
896+
897+
assert mocked_formatter.call_count is 1

todoman/cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,10 @@ def cli(click_ctx, color, porcelain, humanize):
223223
if humanize is None: # False means explicitly disabled
224224
humanize = ctx.config['main']['humanize']
225225

226-
if humanize:
227-
ctx.formatter_class = formatters.HumanizedFormatter
228-
elif porcelain:
226+
if porcelain:
229227
ctx.formatter_class = formatters.PorcelainFormatter
228+
elif humanize:
229+
ctx.formatter_class = formatters.HumanizedFormatter
230230
else:
231231
ctx.formatter_class = formatters.DefaultFormatter
232232

0 commit comments

Comments
 (0)