Skip to content

Commit 9027769

Browse files
committed
fix commander usage
1 parent 01252b6 commit 9027769

File tree

4 files changed

+25
-20
lines changed

4 files changed

+25
-20
lines changed

libV2/tasks/BaseTask.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,20 @@ class BaseTask extends Process {
117117
}
118118

119119
get schedule() {
120-
if (this._program.now) {
120+
const opts = this._program.opts();
121+
if (opts.now) {
121122
return Now;
122123
}
123-
if (this._program.schedule) {
124-
return this._program.schedule;
124+
if (opts.schedule) {
125+
return opts.schedule;
125126
}
126127
return this._defaultSchedule;
127128
}
128129

129130
get lag() {
130-
if (this._program.lag !== undefined) {
131-
return this._program.lag;
131+
const opts = this._program.opts();
132+
if (opts.lag !== undefined) {
133+
return opts.lag;
132134
}
133135
return this._defaultLag;
134136
}

libV2/tasks/DiskUsage.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,15 @@ class MonitorDiskUsage extends BaseTask {
131131
}
132132

133133
get isLeader() {
134-
return this._program.leader !== undefined;
134+
return this._program.opts().leader !== undefined;
135135
}
136136

137137
get isManualUnlock() {
138-
return this._program.unlock !== undefined;
138+
return this._program.opts().unlock !== undefined;
139139
}
140140

141141
get isManualLock() {
142-
return this._program.lock !== undefined;
142+
return this._program.opts().lock !== undefined;
143143
}
144144

145145
async _getUsage(path) {

libV2/tasks/ManualAdjust.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ class ManualAdjust extends BaseTask {
2626
}
2727

2828
async _start() {
29+
const opts = this._program.opts();
2930
this._utapiClient = new UtapiClient({
30-
host: this._program.host,
31-
port: this._program.port,
31+
host: opts.host,
32+
port: opts.port,
3233
disableRetryCache: true,
3334
});
3435
await super._start();
@@ -42,35 +43,36 @@ class ManualAdjust extends BaseTask {
4243
async _execute() {
4344
const timestamp = Date.now();
4445

45-
const objectDelta = this._program.objects;
46-
const sizeDelta = this._program.storage;
46+
const opts = this._program.opts();
47+
const objectDelta = opts.objects;
48+
const sizeDelta = opts.storage;
4749

48-
if (!this._program.bucket.length && !this._program.account.length && !this._program.user.length) {
50+
if (!opts.bucket.length && !opts.account.length && !opts.user.length) {
4951
throw Error('You must provided at least one of --bucket, --account or --user');
5052
}
5153

5254
logger.info('writing adjustments');
53-
if (this._program.bucket.length) {
55+
if (opts.bucket.length) {
5456
logger.info('adjusting buckets');
5557
await async.eachSeries(
56-
this._program.bucket,
58+
opts.bucket,
5759
async bucket => this._pushAdjustmentMetric({
5860
bucket, objectDelta, sizeDelta, timestamp,
5961
}),
6062
);
6163
}
6264

63-
if (this._program.account.length) {
65+
if (opts.account.length) {
6466
logger.info('adjusting accounts');
6567
await async.eachSeries(
66-
this._program.account,
68+
opts.account,
6769
async account => this._pushAdjustmentMetric({
6870
account, objectDelta, sizeDelta, timestamp,
6971
}),
7072
);
7173
}
7274

73-
if (this._program.user.length) {
75+
if (opts.user.length) {
7476
logger.info('adjusting users');
7577
await async.eachSeries(
7678
this._program.user,

libV2/tasks/Reindex.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,9 @@ class ReindexTask extends BaseTask {
158158
}
159159

160160
get targetBuckets() {
161-
if (this._program.bucket.length) {
162-
return this._program.bucket.map(name => ({ name }));
161+
const opts = this._program.opts();
162+
if (opts.bucket.length) {
163+
return opts.bucket.map(name => ({ name }));
163164
}
164165
return metadata.listBuckets();
165166
}

0 commit comments

Comments
 (0)