From 15be18ccb94e8e83a6ecdf3909d948d8a7d5d7c7 Mon Sep 17 00:00:00 2001 From: cupen Date: Mon, 6 May 2024 16:13:47 +0800 Subject: [PATCH] fix: cli --- excel2xx/main.py | 11 +++++++---- excel2xx/version.py | 2 +- setup.py | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/excel2xx/main.py b/excel2xx/main.py index f5d9533..e857899 100644 --- a/excel2xx/main.py +++ b/excel2xx/main.py @@ -2,7 +2,7 @@ """Export data from Excel file. Usage: - excel2xx.py json -o FILE -- [options] + excel2xx.py json -o FILE [options] excel2xx.py msgpack -o FILE [options] excel2xx.py mako --template=FILE [options] excel2xx.py build --from=DIR --to=DIR [options] @@ -55,16 +55,17 @@ def main(args): ) excel = Excel(src, fieldMeta=meta) if args["json"]: - dest = dest or f"{src}.json" + dest = dest or make_fname(src, ".json") export.toJson(excel, dest) elif args["msgpack"]: - dest = dest or f"{src}.msgp" + dest = dest or make_fname(src, ".msgp") export.toMsgPack(excel, dest) elif args["mako"]: template = args["--template"] - if not dest: + if not template: print("Missing '--template', which is mako template file.") return 1 + dest = dest or os.path.splitext(template)[0] export.toMako(excel, dest, template) elif args["build"]: raise NotImplementedError("build is developing.") @@ -88,6 +89,8 @@ def main_docopt(argv=None): return 2 pass +def make_fname(src, ext): + return os.path.splitext(src)[0] + ext if __name__ == "__main__": import sys diff --git a/excel2xx/version.py b/excel2xx/version.py index e582db1..d11a418 100644 --- a/excel2xx/version.py +++ b/excel2xx/version.py @@ -1 +1 @@ -VERSION = "0.11.7" +VERSION = "0.11.8" diff --git a/setup.py b/setup.py index be3ff41..4cc77d2 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ def _open(fname): setup( name="excel2xx", - version="0.11.7", + version="0.11.8", url="https://github.com/cupen/excel2xx", license="WTFPL", author="cupen",