diff --git a/grib_processor/main.py b/grib_processor/main.py index be9a8b0271ac8790fd663eef2158406869cecce1..ea7dfad8fd2472b189ad9feb2c6b27b8ef2c28af 100644 --- a/grib_processor/main.py +++ b/grib_processor/main.py @@ -86,8 +86,10 @@ def setup() -> tuple[Iterable[GribPayload], Callable[[GribPayload], None]]: ) parser.add_argument( "grib_src", + nargs="?", + default=None, metavar="grib_source", - help="Directory to watch for new grib files, file to read grib paths from, or '--' to read file paths from stdin.", + help="Where to get grib files from. Either stdin (default), a directory to watch, or a grib file itself.", ) parser.add_argument( "-v", @@ -161,7 +163,10 @@ def setup() -> tuple[Iterable[GribPayload], Callable[[GribPayload], None]]: # Get an iterator over grib files to process file_iter: Iterable[str] - if os.path.isdir(args.grib_src): + if args.grib_src is None: + LOG.info("Sourcing grib files from stdin, realtime=%s", args.realtime) + file_iter = map(str.strip, iter(sys.stdin.readline, "")) + elif os.path.isdir(args.grib_src): LOG.info( "Sourcing grib files from directory watch @ %s realtime=%s", args.grib_src, @@ -177,11 +182,8 @@ def setup() -> tuple[Iterable[GribPayload], Callable[[GribPayload], None]]: args.grib_src, debounce=debounce, recursive=args.recursive ) elif os.path.isfile(args.grib_src): - LOG.info("Sourcing grib file directly from CLI, %s", args.grib_src) + LOG.info("Grib source is a file, parsing directly, %s", args.grib_src) file_iter = (str(args.grib_src),) - elif args.grib_src == "--": - LOG.info("Sourcing grib files from stdin, realtime=%s", args.realtime) - file_iter = map(str.strip, iter(sys.stdin.readline, "")) else: parser.error("{0} is not a valid source!".format(args.grib_src))