Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x | import { checkDrain } from '../../clever-client/drains.js';
import { defineCommand } from '../../lib/define-command.js';
import { styleText } from '../../lib/style-text.js';
import { Logger } from '../../logger.js';
import { resolveDrainResource } from '../../models/drain.js';
import { sendToApi } from '../../models/send-to-api.js';
import {
addonIdOrRealIdOption,
aliasOption,
appIdOrNameOption,
humanJsonOutputFormatOption,
} from '../global.options.js';
import { drainIdArg } from './drain.args.js';
export const drainCheckCommand = defineCommand({
description: "Check that a drain's recipient is reachable and accepts deliveries",
since: '4.11.0',
options: {
alias: aliasOption,
appIdOrName: appIdOrNameOption,
addonIdOrRealId: addonIdOrRealIdOption,
format: humanJsonOutputFormatOption,
},
args: [drainIdArg],
async handler(options, drainId) {
const { alias, appIdOrName, addonIdOrRealId, format } = options;
const { ownerId, resourceId } = await resolveDrainResource(alias, appIdOrName, addonIdOrRealId);
const probe = await checkDrain({ ownerId, resourceId, drainId }).then(sendToApi);
switch (format) {
case 'json': {
Logger.printJson({ ok: probe.ok, message: probe.message });
break;
}
case 'human':
default: {
const status = probe.ok ? styleText(['bold', 'green'], 'OK') : styleText(['bold', 'red'], 'FAILED');
Logger.println(`Probe: ${status}`);
Logger.println(probe.message);
}
}
},
});
|