Added date and indexed oldest/latest limit arguments.

This commit is contained in:
2024-09-11 05:16:56 +02:00
parent 86002ef00b
commit 24a165cf48
2 changed files with 102 additions and 12 deletions
+19 -2
View File
@@ -4,7 +4,7 @@ const config = require('config');
const yargs = require('yargs');
function getArgs() {
return yargs
const args = yargs
.command('npm start -- --user <username>')
.option('users', {
alias: 'user',
@@ -40,7 +40,18 @@ function getArgs() {
type: 'array',
})
.option('after', {
describe: 'Do not include posts from before this date (DD-MM-YYYY). When set to \'index\', it will assume the date of the latest indexed post.',
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',
options: ['oldest', 'latest'],
})
.option('before-indexed', {
describe: 'Only include posts before the oldest or the latest entry in the index',
options: ['oldest', 'latest'],
})
.option('archives', {
describe: 'Search archives for deleted posts',
@@ -48,6 +59,12 @@ function getArgs() {
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;