StdInCommand: throw exception if required value is missing v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 29 Jul 2018 14:42:50 +0200
branchv_0
changeset 17 f543468a7e49
parent 16 70af16946466
child 18 9e543fd0254c
StdInCommand: throw exception if required value is missing
StdInCommand.h
--- a/StdInCommand.h	Sat Jul 28 22:29:40 2018 +0200
+++ b/StdInCommand.h	Sun Jul 29 14:42:50 2018 +0200
@@ -48,6 +48,8 @@
 				if (ch == 0 || input.eof() || input.fail()) break;
 				else value << ch;
 			}
+			
+			if (required && value.str().empty()) throw RelpipeCLIException(L"Missing value on STDIN.", CLI::EXIT_CODE_BAD_SYNTAX);
 
 			return convertor.from_bytes(value.str());
 		}
@@ -80,6 +82,7 @@
 			string_t value = readNext(input, arguments, i, false);
 			if (value.empty() && (input.eof() || input.fail())) break;
 			else writer->writeAttribute(value);
+			// TODO: check attribute count (avoid unfinished records)
 		}
 	}
 };