##// END OF EJS Templates
Explicitly tell fileinput that we use '-' as read source...
marcink -
r3881:6b21a93d beta
parent child Browse files
Show More
@@ -36,7 +36,7 b' from rhodecode.bin.base import json, api'
36 def argparser(argv):
36 def argparser(argv):
37 usage = (
37 usage = (
38 "rhodecode-gist [-h] [--format=FORMAT] [--apikey=APIKEY] [--apihost=APIHOST] "
38 "rhodecode-gist [-h] [--format=FORMAT] [--apikey=APIKEY] [--apihost=APIHOST] "
39 "[--config=CONFIG] [--save-config] "
39 "[--config=CONFIG] [--save-config] [GIST OPTIONS] "
40 "[filename or stdin use - for terminal stdin ]\n"
40 "[filename or stdin use - for terminal stdin ]\n"
41 "Create config file: rhodecode-gist --apikey=<key> --apihost=http://rhodecode.server --save-config"
41 "Create config file: rhodecode-gist --apikey=<key> --apihost=http://rhodecode.server --save-config"
42 )
42 )
@@ -48,20 +48,22 b' def argparser(argv):'
48 group = parser.add_argument_group('config')
48 group = parser.add_argument_group('config')
49 group.add_argument('--apikey', help='api access key')
49 group.add_argument('--apikey', help='api access key')
50 group.add_argument('--apihost', help='api host')
50 group.add_argument('--apihost', help='api host')
51 group.add_argument('--config', help='config file')
51 group.add_argument('--config', help='config file path DEFAULT: ~/.rhodecode')
52 group.add_argument('--save-config', action='store_true',
52 group.add_argument('--save-config', action='store_true',
53 help='save the given config into a file')
53 help='save the given config into a file')
54
54
55 group = parser.add_argument_group('GIST')
55 group = parser.add_argument_group('GIST')
56 group.add_argument('-f', '--filename', help='set uploaded gist filename')
57 group.add_argument('-p', '--private', action='store_true',
56 group.add_argument('-p', '--private', action='store_true',
58 help='Create private Gist')
57 help='create private Gist')
58 group.add_argument('-f', '--filename',
59 help='set uploaded gist filename, '
60 'also defines syntax highlighting')
59 group.add_argument('-d', '--description', help='Gist description')
61 group.add_argument('-d', '--description', help='Gist description')
60 group.add_argument('-l', '--lifetime', metavar='MINUTES',
62 group.add_argument('-l', '--lifetime', metavar='MINUTES',
61 help='Gist lifetime in minutes, -1 (Default) is forever')
63 help='gist lifetime in minutes, -1 (DEFAULT) is forever')
62 group.add_argument('--format', dest='format', type=str,
64 group.add_argument('--format', dest='format', type=str,
63 help='output format default: `%s` can '
65 help='output format DEFAULT: `%s` can '
64 'be also `%s`' % (FORMAT_PRETTY, FORMAT_JSON),
66 'be also `%s`' % (FORMAT_PRETTY, FORMAT_JSON),
65 default=FORMAT_PRETTY
67 default=FORMAT_PRETTY
66 )
68 )
67 args, other = parser.parse_known_args()
69 args, other = parser.parse_known_args()
@@ -97,7 +99,7 b' def _run(argv):'
97 if filename == '-':
99 if filename == '-':
98 filename = DEFAULT_FILENAME
100 filename = DEFAULT_FILENAME
99 gist_content = ''
101 gist_content = ''
100 for line in fileinput.input():
102 for line in fileinput.input('-'):
101 gist_content += line
103 gist_content += line
102 else:
104 else:
103 with open(filename, 'rb') as f:
105 with open(filename, 'rb') as f:
@@ -160,6 +162,7 b' def main(argv=None):'
160 try:
162 try:
161 return _run(argv)
163 return _run(argv)
162 except Exception, e:
164 except Exception, e:
165 raise
163 print e
166 print e
164 return 1
167 return 1
165
168
General Comments 0
You need to be logged in to leave comments. Login now