summaryrefslogtreecommitdiff
path: root/summain
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2011-02-18 23:08:35 +0000
committerLars Wirzenius <liw@liw.fi>2011-02-18 23:08:35 +0000
commit4707f32a416dfb8e6a6956bb1e2fe60997cc9f4b (patch)
treeb1ca9a42d1554bfdff2d2dd652d11737baf53f97 /summain
parentfa78ecc93fe9f4d1638c38e7e9023dc0ca5fd35f (diff)
downloadsummain-4707f32a416dfb8e6a6956bb1e2fe60997cc9f4b.tar.gz
Implement relative path output.
Diffstat (limited to 'summain')
-rwxr-xr-xsummain7
1 files changed, 6 insertions, 1 deletions
diff --git a/summain b/summain
index 58ac582..c37e57c 100755
--- a/summain
+++ b/summain
@@ -24,6 +24,10 @@ import summainlib
class Summain(cliapp.Application):
+ def add_settings(self):
+ self.add_boolean_setting(['relative-paths', 'r'],
+ 'print paths relative to arguments')
+
def files(self, root):
if os.path.isdir(root):
for dirname, dirnames, filenames in os.walk(root):
@@ -34,11 +38,12 @@ class Summain(cliapp.Application):
yield root
def process_args(self, args):
+ relative = self['relative-paths']
normalizer = summainlib.NumberNormalizer()
for root in args:
for filename in self.files(root):
o = summainlib.FilesystemObject(filename, normalizer)
- sys.stdout.write(o.format())
+ sys.stdout.write(o.format(root if relative else None))
sys.stdout.write('\n')