Convert to new file arguments.
@@ -8,7 +8,7 @@ from argparse import Namespace, SUPPRESS
from pathlib import Path
import typing
-from kgtk.cli_argparse import KGTKArgumentParser
+from kgtk.cli_argparse import KGTKArgumentParser, KGTKFiles
def parser():
return {
@@ -41,12 +41,9 @@ def add_arguments_extended(parser: KGTKArgumentParser, parsed_shared_args: Names
else:
return SUPPRESS
- parser.add_argument("-i", "--input-file", dest="input_kgtk_file", metavar="INPUT_FILE",
- help="The KGTK input file. May be omitted or '-' for stdin. (default=%(default)s).",
- type=Path, default="-")
+ parser.add_input_file(allow_positional=True)
+ parser.add_output_file()
- parser.add_argument("-o", "--output-file", dest="output_kgtk_file", metavar="OUTPUT_FILE",
- help="The KGTK file to write. May be omitted or '-' for stdout. (default=%(default)s).", type=Path, default="-")
parser.add_argument( "--output-format", dest="output_format", help=h("The file format (default=kgtk)"), type=str)
parser.add_argument('-c', "--columns", dest="column_names", required=True, nargs='+',
@@ -63,8 +60,8 @@ def add_arguments_extended(parser: KGTKArgumentParser, parsed_shared_args: Names
KgtkReaderOptions.add_arguments(parser, mode_options=True, expert=_expert)
KgtkValueOptions.add_arguments(parser, expert=_expert)
-def run(input_kgtk_file: Path,
- output_kgtk_file: Path,
+def run(input_file: KGTKFiles,
+ output_file: KGTKFiles,
output_format: typing.Optional[str],
column_names: typing.List[str],
@@ -87,6 +84,8 @@ def run(input_kgtk_file: Path,
from kgtk.io.kgtkwriter import KgtkWriter
from kgtk.value.kgtkvalueoptions import KgtkValueOptions
+ input_kgtk_file: Path = KGTKArgumentParser.get_required_input_file(input_file)
+ output_kgtk_file: Path = KGTKArgumentParser.get_required_output_file(output_file)
# Select where to send error messages, defaulting to stderr.
error_file: typing.TextIO = sys.stdout if errors_to_stdout else sys.stderr
