summaryrefslogtreecommitdiff
path: root/fs/commands/fscat.py
blob: 2849ce129b32cf4b7ef1dc24b811452af41f7385 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python
from fs.commands.runner import Command
import sys

class FSCat(Command):
    
    usage = """fscat [OPTION]... [FILE]...
Concetanate FILE(s)"""

    version = "1.0"
    
    def do_run(self, options, args):
        count = 0            
        for fs, path, is_dir in self.get_resources(args):            
            if is_dir:
                self.error('%s is a directory\n' % path)
                return 1                      
            self.output(fs.getcontents(path))
            count += 1              
        if self.is_terminal() and count:
            self.output('\n')
    
def run():
    return FSCat().run()
    
if __name__ == "__main__":
    sys.exit(run())