aboutsummaryrefslogtreecommitdiff
path: root/loader
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-12-15 13:38:57 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-12-15 13:38:57 +0200
commitef9615aebb8a7b504c3b5cd2610e3c8f5bb4de58 (patch)
treeaca0be97a87005f177d0e015f132b117726cfe12 /loader
parentd43e00ba64a5332100a8a2330d251051302b0193 (diff)
Various cleanups and improvements, INSTALL-DEV instructions
Diffstat (limited to 'loader')
-rw-r--r--loader/loader.cxx28
-rw-r--r--loader/options.cli38
2 files changed, 46 insertions, 20 deletions
diff --git a/loader/loader.cxx b/loader/loader.cxx
index 7d8570a..4512b8d 100644
--- a/loader/loader.cxx
+++ b/loader/loader.cxx
@@ -38,13 +38,13 @@ using namespace brep;
namespace pgsql = odb::pgsql;
static void
-usage ()
+usage (ostream& os)
{
- cout << "Usage: brep-loader [options] <file>" << endl
- << "File lists internal repositories." << endl
- << "Options:" << endl;
+ os << "Usage: brep-loader [options] <file>" << endl
+ << "File lists internal repositories." << endl
+ << "Options:" << endl;
- options::print_usage (cout);
+ options::print_usage (os);
}
static inline bool
@@ -715,25 +715,29 @@ main (int argc, char* argv[])
//
if (ops.help ())
{
- usage ();
+ usage (cout);
return 0;
}
if (argc < 2)
{
- cout << "<file> argument not provided" << endl;
- usage ();
+ cerr << "<file> argument not provided" << endl;
+ usage (cerr);
return 1;
}
if (argc > 2)
{
- cout << "unexpected argument encountered" << endl;
- usage ();
+ cerr << "unexpected argument encountered" << endl;
+ usage (cerr);
return 1;
}
- pgsql::database db ("", "", "brep", ops.db_host (), ops.db_port ());
+ pgsql::database db (ops.db_user (),
+ ops.db_password (),
+ ops.db_name (),
+ ops.db_host (),
+ ops.db_port ());
// Prevent several loader instances from updating DB simultaneously.
//
@@ -825,7 +829,7 @@ main (int argc, char* argv[])
catch (const cli::exception& e)
{
cerr << e << endl;
- usage ();
+ usage (cerr);
return 1;
}
// Fully qualified to avoid ambiguity with odb exception.
diff --git a/loader/options.cli b/loader/options.cli
index 7045a22..e46a548 100644
--- a/loader/options.cli
+++ b/loader/options.cli
@@ -8,19 +8,41 @@ namespace brep
{
class options
{
- bool --help {"Print usage information and exit."};
- bool --version {"Print version and exit."};
+ bool --help {"Print usage information and exit."}
+ bool --version {"Print version and exit."}
- string --db-host = "localhost"
+ string --db-user|-u
+ {
+ "<user>",
+ "Database user name. If not specified, then operating system (login)
+ name is used."
+ }
+
+ string --db-password
+ {
+ "<pass>",
+ "Database password. If not specified, then login without password is
+ expected to work."
+ }
+
+ string --db-name|-n = "brep"
+ {
+ "<name>",
+ "Database name. If not specified, then '\cb{brep}' is used by default."
+ }
+
+ string --db-host|-h
{
"<host>",
- "Connect database server using specified host or socket directory."
- };
+ "Database host name, address, or socket. If not specified, then connect
+ to \cb{localhost} using the operating system-default mechanism
+ (Unix-domain socket, etc)."
+ }
- uint16_t --db-port = 5432
+ uint16_t --db-port|-p = 0
{
"<port>",
- "Connect database server using specified port."
- };
+ "Database port number. If not specified, the default port is used."
+ }
};
}