diff options
author | rsiddharth <s@ricketyspace.net> | 2017-06-04 23:35:49 +0000 |
---|---|---|
committer | rsiddharth <s@ricketyspace.net> | 2017-06-04 23:42:45 +0000 |
commit | 5dde967f0907460d5bacf5634f6e9ecd955a3f70 (patch) | |
tree | da6f078e1bd387860701836111ed9e028e3568f8 /mdl_style.py | |
parent | dd3972a722514d9c49813fe1d05ee24dcf1ecb95 (diff) |
mdl_style: Update _get_args.
mdl_style.py (_mdl_stylize): Update function.
(_get_args): Update function.
README.rst: Update file.
Diffstat (limited to 'mdl_style.py')
-rw-r--r-- | mdl_style.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/mdl_style.py b/mdl_style.py index 46e819d..eb6ed12 100644 --- a/mdl_style.py +++ b/mdl_style.py @@ -249,8 +249,13 @@ def _write_to(file_, content): def _mdl_stylize(args): ls = LinkStyler(args.link_style) - print(ls(args.file), end='') + stylized_content = ls(args.in_file) + if args.out_file: + args.in_file.close() + _write_to(open(args.out_file, 'wt'), stylized_content) + else: + _write_to(args.in_file, stylized_content) def _get_args(args=None): @@ -259,8 +264,16 @@ def _get_args(args=None): version=__version__) parser.add_argument('link_style', choices=['inline', 'footnote'], help='markdown link style.') - parser.add_argument('file', type=argparse.FileType('r'), + parser.add_argument('in_file', type=argparse.FileType('rt+'), help='path to markdown file.') + parser.add_argument('out_file', nargs='?', + type=str, + default=None, + help= ' '.join(['path to output file.', + 'if it is not given, the output is', + 'directly written to the original', + 'in_file.'])) + return parser.parse_args(args) |