Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making refresh rate controllable from CLI #30

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion env.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = function() {
.option('--changes-limit [value]', 'number of changes to batch')
.option('--postgres-table [value]', 'name of the postgres table to replicate to')
.option('-d, --daemon', 'continually replicate between CouchDB and PostgresSQL')
.option('-s, --sleep', 'Sleep interval in milliseconds between runs in daemon mode (default 10 * 60 * 60 * 1000 [ms] = 10 hrs)')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we come up with a better name for this parameter? I'm thinking --sleep-interval or --polling-interval or something more descriptive?

Secondly, commander allows setting defaults which would save a little code later on, eg:

Suggested change
.option('-s, --sleep', 'Sleep interval in milliseconds between runs in daemon mode (default 10 * 60 * 60 * 1000 [ms] = 10 hrs)')
.option('-s, --sleep', 'Sleep interval in milliseconds between runs in daemon mode', 10 * 60 * 60 * 1000)

There are even more complicated options if you want to parse the variable or provide a human readable default value. More info in their documentation.

.option('-v, --verbose', 'verbose logging')
.action(function(source, target) {
couchdbUrl = source;
Expand Down Expand Up @@ -44,7 +45,7 @@ module.exports = function() {
couch2pgDocLimit: program['doc-limit'],
couch2pgChangesLimit: program['changes-limit'],
continuous: program.daemon,
sleepMs: 10 * 60 * 60 * 1000,
sleepMs: program['sleep'] || 10 * 60 * 60 * 1000,
postgresTable: program['postgres-table'] || 'couchdb'
};
};