2017-02-16 03:27:16 +00:00
|
|
|
/* jslint node: true */
|
|
|
|
/* eslint-disable no-console */
|
|
|
|
'use strict';
|
|
|
|
|
2022-06-05 20:04:25 +00:00
|
|
|
const ExitCodes = require('./oputil_common.js').ExitCodes;
|
|
|
|
const argv = require('./oputil_common.js').argv;
|
|
|
|
const printUsageAndSetExitCode = require('./oputil_common.js').printUsageAndSetExitCode;
|
|
|
|
const handleUserCommand = require('./oputil_user.js').handleUserCommand;
|
|
|
|
const handleFileBaseCommand = require('./oputil_file_base.js').handleFileBaseCommand;
|
|
|
|
const handleMessageBaseCommand =
|
|
|
|
require('./oputil_message_base.js').handleMessageBaseCommand;
|
|
|
|
const handleConfigCommand = require('./oputil_config.js').handleConfigCommand;
|
2023-03-18 00:40:54 +00:00
|
|
|
const handleApCommand = require('./activitypub').handleUserCommand;
|
2022-06-05 20:04:25 +00:00
|
|
|
const getHelpFor = require('./oputil_help.js').getHelpFor;
|
2017-02-16 03:27:16 +00:00
|
|
|
|
2022-06-05 20:04:25 +00:00
|
|
|
module.exports = function () {
|
2018-06-22 05:15:04 +00:00
|
|
|
process.exitCode = ExitCodes.SUCCESS;
|
2017-02-16 03:27:16 +00:00
|
|
|
|
2022-06-05 20:04:25 +00:00
|
|
|
if (true === argv.version) {
|
2018-11-16 05:21:45 +00:00
|
|
|
return console.info(require('../../package.json').version);
|
2018-06-22 05:15:04 +00:00
|
|
|
}
|
2017-02-16 03:27:16 +00:00
|
|
|
|
2022-06-05 20:04:25 +00:00
|
|
|
if (0 === argv._.length || 'help' === argv._[0]) {
|
2018-06-22 05:15:04 +00:00
|
|
|
return printUsageAndSetExitCode(getHelpFor('General'), ExitCodes.SUCCESS);
|
|
|
|
}
|
2017-02-16 03:27:16 +00:00
|
|
|
|
2022-06-05 20:04:25 +00:00
|
|
|
switch (argv._[0]) {
|
|
|
|
case 'user':
|
|
|
|
return handleUserCommand();
|
|
|
|
case 'config':
|
|
|
|
return handleConfigCommand();
|
|
|
|
case 'fb':
|
|
|
|
return handleFileBaseCommand();
|
|
|
|
case 'mb':
|
|
|
|
return handleMessageBaseCommand();
|
2023-03-18 00:40:54 +00:00
|
|
|
case 'ap':
|
|
|
|
return handleApCommand();
|
2022-06-05 20:04:25 +00:00
|
|
|
default:
|
|
|
|
return printUsageAndSetExitCode(getHelpFor('General'), ExitCodes.BAD_COMMAND);
|
2018-06-22 05:15:04 +00:00
|
|
|
}
|
2017-02-16 03:27:16 +00:00
|
|
|
};
|