-
-
Notifications
You must be signed in to change notification settings - Fork 150
ledgersmb admin
Scripting: As a developer, I need ways to set up various test scenarios quickly. Over the past years, the 'quickly' part is what was missing: setup was manual through setup.pl
and any prerequisites (customers, taxes, etc.) had to be set up manually through the UI. All of that takes a lot of time. Time that could have been spent debugging the problem or developing new functionality.
With the new CLI, it becomes easier to script setup of base scenarios for debugging as well as restoring a specific testing setup.
Administrators may also benefit from having a tool to work with from the command-line, allowing them to disable the 'setup.pl' access.
The CLI features a command line structure similar to that of git
and docker
:
ledgersmb-admin [<global-options>] <command> [<options>] <sub-command> [<more options>]
some examples:
ledgersmb-admin create my_company_database
ledgersmb-admin setup load my/setup.xml
ledgersmb-admin template list
NOTE The examples above don't include a database name (or even cluster) to operate against. Contrary to git
which is run from a repository which stores information regarding remotes and thus has knowledge of a default remote (or operates locally), the ledgersmb-admin
tool does not have a local directory such as a repository.
Due to the lack of local storage, each command will need to specify at least a database name and/or a postgresql database server (in sofar these aren't provided through the configuration file).
Questions to be answered to design a good UI in line with docker
/git
:
-
docker exec <container> <command>
: requires explicit naming of the container; do we want a similar pattern forledgersmb-admin
ledgersmb-admin setup load my_company_database my/setup.xml
? -
git clone <repo-url>
feels really intuitive;psql -h localhost -p 2244 -U postgres -d my_company_database
feels cumbersome; do we want the pattern forledgersmb-admin
to be
ledgersmb-admin setup postgres@remotehost:2244/my_company_database my/setup.xml
to address the database?- if we do, do we want to support setting a default database in the configuration files? How should the default be selected?
- how do we combine the explicit components from the URI above with the defaults from the configuration file? (Do we parse the URI ourselves, even though libpq can do it for us?)
The tool resolves configuration (e.g. which postgresql server to connect to) in the following order (in decending priority):
- Command line
- Configuration file
- ./.ledgersmb-admin.yaml
- ~/.ledgersmb-admin.yaml
- /usr/local/etc/ledgersmb-admin.yaml
- /etc/ledgersmb-admin.yaml
- Environment variables (
PG*
)
There is full support for libpq
's configuration files ./.pg_pass
, ~/.pg_pass
, ~/.pg_service.conf
and $PGSYSCONFDIR/pg_service.conf
.