aboutsummaryrefslogtreecommitdiff
path: root/libbutl/manifest.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-04-08 16:36:39 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2019-04-08 18:35:10 +0300
commit8b0fe501e77a1f4032a396b97ad317f09e160ee3 (patch)
tree54b59aa6fb696d12e2eaac711fe35246627bf0a4 /libbutl/manifest.cxx
parentc66eacd1d56cebce6986217bf6ea321018323952 (diff)
Add support for manifest serializing long lines mode
Diffstat (limited to 'libbutl/manifest.cxx')
-rw-r--r--libbutl/manifest.cxx27
1 files changed, 22 insertions, 5 deletions
diff --git a/libbutl/manifest.cxx b/libbutl/manifest.cxx
index d095c45..b3811a5 100644
--- a/libbutl/manifest.cxx
+++ b/libbutl/manifest.cxx
@@ -81,7 +81,7 @@ cmd_parse ()
}
static int
-cmd_serialize ()
+cmd_serialize (bool long_lines)
{
using serializer = manifest_serializer;
using serialization = manifest_serialization;
@@ -97,7 +97,7 @@ cmd_serialize ()
cout.exceptions (ios::badbit | ios::failbit);
- serializer s (cout, "stdout");
+ serializer s (cout, "stdout", long_lines);
for (string l; !eof (getline (cin, l, '\0')); )
{
@@ -132,21 +132,38 @@ cmd_serialize ()
return 0;
}
+// Usages:
+//
+// argv[0] parse
+// argv[0] [--long-lines] serialize
+//
int
main (int argc, char* argv[])
{
// We should switch to CLI if we need anything more elaborate.
//
- if (argc < 2)
+ int i (1);
+ bool long_lines (false);
+ for (; i != argc; ++i)
+ {
+ string op (argv[i]);
+
+ if (op == "--long-lines")
+ long_lines = true;
+ else
+ break;
+ }
+
+ if (i == argc)
{
cerr << "error: missing command" << endl;
return 1;
}
- string c (argv[1]);
+ string c (argv[i]);
if (c == "parse") return cmd_parse ();
- if (c == "serialize") return cmd_serialize ();
+ if (c == "serialize") return cmd_serialize (long_lines);
cerr << "error: unknown command '" << c << "'" << endl;
return 1;