ripunzel/src/cli.js

95 lines
3.2 KiB
JavaScript

'use strict';
const config = require('config');
const yargs = require('yargs');
function getArgs() {
const args = yargs
.command('npm start -- --user <username>')
.option('users', {
alias: 'user',
describe: 'Reddit usernames to fetch posts from',
type: 'array',
})
.option('file-users', {
describe: 'Load reddit usernames from file',
type: 'string',
})
.option('posts', {
alias: 'post',
describe: 'Reddit post IDs to fetch',
type: 'array',
})
.option('file-posts', {
describe: 'Load reddit post IDs from file',
type: 'string',
})
.option('limit', {
describe: 'Maximum amount of posts to fetch per supplied user (!), after filtering out ignored, cross- and reposts',
type: 'number',
default: config.fetch.limit,
})
.option('sort', {
describe: 'Property to sort posts by',
choices: ['new', 'top', 'hot', 'controversial'],
default: config.fetch.sort,
})
.option('ignore', {
describe: 'Ignore posts with any of these properties',
type: 'array',
choices: ['pinned', 'stickied', 'hidden', 'spoiler', 'over_18'],
})
.option('file-ignore', {
describe: 'Ignore the host IDs in this file',
type: 'string',
})
.option('include', {
describe: 'Include only these sources',
type: 'array',
})
.option('exclude', {
describe: 'Do not include these sources',
type: 'array',
})
.option('after', {
describe: 'Only include posts after this date (YYYY-MM-DD, optionally HH:mm)',
})
.option('before', {
describe: 'Only include posts before this date (YYYY-MM-DD, optionally HH:mm)',
})
.option('after-indexed', {
describe: 'Only include posts after the oldest or the latest entry in the index',
choices: ['oldest', 'latest'],
})
.option('before-indexed', {
describe: 'Only include posts before the oldest or the latest entry in the index',
choices: ['oldest', 'latest'],
})
.option('redownload', {
describe: 'Ignore index file and force a redownload of everything in the selection. Does not affect [before|after]-indexed',
type: 'boolean',
})
.option('redownload-profile', {
describe: 'Ignore index file and force a redownload of the profile image and description',
type: 'boolean',
})
.option('watch', {
describe: 'Keep the process running and periodically check for new posts',
type: 'boolean',
})
.option('archives', {
describe: 'Search archives for deleted posts',
type: 'boolean',
default: config.fetch.archives.search,
})
.argv;
return {
...args,
after: args.after ? new Date(args.after) : null,
before: args.before ? new Date(args.before) : null,
};
}
module.exports = getArgs;