Skip to content

Commit 52b2f4d

Browse files
committed
optimize command fetch-unread: support more output formats
1 parent b177b5d commit 52b2f4d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

inoreader/main.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def add_unread_fetch_parser(subparsers):
142142
parser.add_argument("-o", "--outfile", required=True, help="Filename to save articles")
143143
parser.add_argument(
144144
"--out-format",
145-
choices=['json', 'csv', 'plain'],
145+
choices=['json', 'csv', 'plain', 'markdown', 'org-mode'],
146146
default='json',
147147
help='Format of output file, default: json'
148148
)
@@ -167,6 +167,12 @@ def fetch_unread(folder, tags, outfile, out_format):
167167
print('TITLE: {}'.format(title), file=fout)
168168
print("CONTENT: {}".format(text), file=fout)
169169
print(file=fout)
170+
elif out_format == 'markdown':
171+
print('# {}\n'.format(title), file=fout)
172+
print(text + '\n', file=fout)
173+
elif out_format == 'org-mode':
174+
print('* {}\n'.format(title), file=fout)
175+
print(text + '\n', file=fout)
170176

171177
print("[{}] fetched {} articles and saved them in {}".format(datetime.now(), idx + 1, outfile))
172178

0 commit comments

Comments
 (0)