Mercurial > hg
comparison tests/test-command-template.t @ 20370:aa51392da507
template: add pad function for padding output
Adds a pad template function with the following signature:
pad(text, width, fillchar=' ', right=False)
This uses the standard python ljust and rjust functions to produce a string
that is at least a certain width. This is useful for aligning variable length
strings in log output (like user names or shortest(node) output).
author | Durham Goode <durham@fb.com> |
---|---|
date | Fri, 17 Jan 2014 00:16:48 -0800 |
parents | 9c6b86dd2ed2 |
children | 1e43f15a647f |
comparison
equal
deleted
inserted
replaced
20369:9c6b86dd2ed2 | 20370:aa51392da507 |
---|---|
1635 d97c | 1635 d97c |
1636 f776 | 1636 f776 |
1637 $ hg log --template '{shortest(node, 10)}\n' | 1637 $ hg log --template '{shortest(node, 10)}\n' |
1638 d97c383ae3 | 1638 d97c383ae3 |
1639 f7769ec2ab | 1639 f7769ec2ab |
1640 | |
1641 Test pad function | |
1642 | |
1643 $ hg log --template '{pad(rev, 20)} {author|user}\n' | |
1644 1 test | |
1645 0 test | |
1646 | |
1647 $ hg log --template '{pad(rev, 20, " ", True)} {author|user}\n' | |
1648 1 test | |
1649 0 test | |
1650 | |
1651 $ hg log --template '{pad(rev, 20, "-", False)} {author|user}\n' | |
1652 1------------------- test | |
1653 0------------------- test |