2018-04-29 00:02:34 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const config = require('config');
|
|
|
|
const yargs = require('yargs');
|
|
|
|
|
2018-06-16 23:11:10 +00:00
|
|
|
function getArgs() {
|
2018-06-30 22:07:12 +00:00
|
|
|
const args = yargs
|
2018-06-30 01:33:30 +00:00
|
|
|
.command('npm start -- --user <username>')
|
|
|
|
.option('users', {
|
|
|
|
alias: 'user',
|
|
|
|
describe: 'Reddit usernames to fetch posts from',
|
|
|
|
type: 'array',
|
|
|
|
})
|
2018-07-01 22:25:48 +00:00
|
|
|
.option('file-users', {
|
|
|
|
describe: 'Load reddit usernames from file',
|
|
|
|
type: 'string',
|
|
|
|
})
|
2018-06-30 01:33:30 +00:00
|
|
|
.option('posts', {
|
|
|
|
alias: 'post',
|
|
|
|
describe: 'Reddit post IDs to fetch',
|
|
|
|
type: 'array',
|
|
|
|
})
|
2018-07-01 22:25:48 +00:00
|
|
|
.option('file-posts', {
|
|
|
|
describe: 'Load reddit post IDs from file',
|
|
|
|
type: 'string',
|
|
|
|
})
|
2019-11-01 03:22:36 +00:00
|
|
|
.option('direct', {
|
|
|
|
describe: 'Get content directly from imgur and other hosts',
|
|
|
|
type: 'string',
|
|
|
|
alias: 'fetch',
|
|
|
|
})
|
2019-11-01 04:55:55 +00:00
|
|
|
.option('file-direct', {
|
|
|
|
describe: 'Load direct content URLs from file',
|
|
|
|
type: 'string',
|
|
|
|
alias: 'file-fetch',
|
|
|
|
})
|
2019-11-02 01:19:23 +00:00
|
|
|
.option('label', {
|
|
|
|
describe: 'Arbitrary variable made available in path patterns. Useful to organize files from a URL lists in directory.',
|
|
|
|
type: 'string',
|
|
|
|
})
|
|
|
|
.option('base', {
|
|
|
|
describe: 'Alternative base path, overriding both the default posts and direct base paths.',
|
|
|
|
type: 'string',
|
|
|
|
})
|
2018-06-30 01:33:30 +00:00
|
|
|
.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'],
|
|
|
|
})
|
2018-07-02 00:33:34 +00:00
|
|
|
.option('file-ignore', {
|
|
|
|
describe: 'Ignore the host IDs in this file',
|
|
|
|
type: 'string',
|
|
|
|
})
|
2018-06-30 01:33:30 +00:00
|
|
|
.option('include', {
|
|
|
|
describe: 'Include only these sources',
|
|
|
|
type: 'array',
|
|
|
|
})
|
|
|
|
.option('exclude', {
|
|
|
|
describe: 'Do not include these sources',
|
|
|
|
type: 'array',
|
|
|
|
})
|
|
|
|
.option('after', {
|
2018-06-30 22:07:12 +00:00
|
|
|
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', {
|
2018-07-07 22:18:51 +00:00
|
|
|
alias: 'after-index',
|
2018-06-30 22:07:12 +00:00
|
|
|
describe: 'Only include posts after the oldest or the latest entry in the index',
|
2018-07-06 22:58:15 +00:00
|
|
|
choices: ['oldest', 'latest'],
|
2018-06-30 22:07:12 +00:00
|
|
|
})
|
|
|
|
.option('before-indexed', {
|
2018-07-07 22:18:51 +00:00
|
|
|
alias: 'before-index',
|
2018-06-30 22:07:12 +00:00
|
|
|
describe: 'Only include posts before the oldest or the latest entry in the index',
|
2018-07-06 22:58:15 +00:00
|
|
|
choices: ['oldest', 'latest'],
|
2018-06-30 01:33:30 +00:00
|
|
|
})
|
2018-06-30 22:22:17 +00:00
|
|
|
.option('redownload', {
|
|
|
|
describe: 'Ignore index file and force a redownload of everything in the selection. Does not affect [before|after]-indexed',
|
|
|
|
type: 'boolean',
|
|
|
|
})
|
2018-07-01 01:26:26 +00:00
|
|
|
.option('redownload-profile', {
|
|
|
|
describe: 'Ignore index file and force a redownload of the profile image and description',
|
|
|
|
type: 'boolean',
|
|
|
|
})
|
2018-07-07 00:17:41 +00:00
|
|
|
.option('index-ignored', {
|
|
|
|
describe: 'Add posts specified to be ignored to the index file, but don\'t download them',
|
|
|
|
type: 'boolean',
|
|
|
|
})
|
2018-07-01 01:06:57 +00:00
|
|
|
.option('watch', {
|
|
|
|
describe: 'Keep the process running and periodically check for new posts',
|
|
|
|
type: 'boolean',
|
|
|
|
})
|
2018-06-30 01:33:30 +00:00
|
|
|
.option('archives', {
|
|
|
|
describe: 'Search archives for deleted posts',
|
|
|
|
type: 'boolean',
|
|
|
|
default: config.fetch.archives.search,
|
|
|
|
})
|
|
|
|
.argv;
|
2018-06-30 22:07:12 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
...args,
|
|
|
|
after: args.after ? new Date(args.after) : null,
|
|
|
|
before: args.before ? new Date(args.before) : null,
|
|
|
|
};
|
2018-06-16 23:11:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = getArgs;
|