diff options
author | Florian Pritz <bluewind@xssn.at> | 2009-10-03 21:38:55 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xssn.at> | 2009-10-03 21:38:55 +0200 |
commit | 578af9df6bf801d42a5b8cd1604550b8cfa342bb (patch) | |
tree | 6932508664a55701075f8c2fb96eb4960af32c21 /fb | |
parent | b6310b067ed26ab874ed38c880ac2647a96aa7a3 (diff) | |
download | bin-578af9df6bf801d42a5b8cd1604550b8cfa342bb.tar.gz bin-578af9df6bf801d42a5b8cd1604550b8cfa342bb.tar.xz |
fb: add support for -e extension (stdin only)
use this if you pipe code or diff and want the highlighting to work
Signed-off-by: Florian Pritz <bluewind@xssn.at>
Diffstat (limited to 'fb')
-rwxr-xr-x | fb | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -8,7 +8,7 @@ #---------------------------------------------------- '''[cat |] %prog [file1 file2 ...]''' -__version__ = '0.4.0' +__version__ = '0.4.1' __desc__ = ''' Upload file to paste.xinu.at and copy URL to clipboard or nopaste stdin @@ -62,7 +62,7 @@ def merge(seq): merged.append(x) return merged -def read_stdin(): +def read_stdin(tmpfile): if os.isatty(sys.stdin.fileno()): print '^C to exit, ^D to send' try: @@ -71,7 +71,6 @@ def read_stdin(): sys.exit() if not content: sys.exit() - tmpfile = Popen('mktemp', stdout=PIPE).communicate()[0] tmpfile = tmpfile.replace('\n', '') f = open(tmpfile, 'w') f.write(content) @@ -84,9 +83,13 @@ def main(): description=__desc__+password.__doc__) p.add_option('-d', '--delete', action='store_true', dest='delete', help='delete IDs', default=False) + p.add_option('-e', '--extension', action='store', dest='extension', + help='extension for tempfiles when pipeing (e.g. "diff")', default='') options, args = p.parse_args() tmpfiles = [] + tmpdir = Popen(['mktemp', '-d'], stdout=PIPE).communicate()[0] + tmpdir = tmpdir.replace('\n', '') if args: for arg in args: if options.delete: @@ -94,8 +97,6 @@ def main(): continue if arg.find('http://') != -1: - tmpdir = Popen(['mktemp', '-d'], stdout=PIPE).communicate()[0] - tmpdir = tmpdir.replace('\n', '') os.chdir(tmpdir) tmpfiles.append(tmpdir) Popen(['wget', '-q', arg]).communicate()[0] @@ -104,7 +105,7 @@ def main(): else: do_upload(arg) else: - tmpfile = read_stdin() + tmpfile = read_stdin(tmpdir+"/stdin."+options.extension) tmpfiles.append(tmpfile) do_upload(tmpfile) |