Skip to content

Commit 9e8ebd5

Browse files
committed
Add author filter to add-author
1 parent c85ebb4 commit 9e8ebd5

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,9 @@ gctools add-author --help
359359

360360
# Add author with the slug 'michael' to the posts with the tag 'news`
361361
gctools add-author <apiURL> <adminAPIKey> --tag 'news' --new_author 'michael'
362+
363+
# For posts that have 'richard' as an author and with the tag 'news', add 'michael' as an author
364+
gctools add-author <apiURL> <adminAPIKey> --author 'richard' --tag 'news' --new_author 'michael'
362365
```
363366

364367

commands/add-author.js

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ const setup = (sywac) => {
2424
defaultValue: false,
2525
desc: 'Show verbose output'
2626
});
27+
sywac.string('--author', {
28+
defaultValue: null,
29+
desc: 'Current author slug'
30+
});
2731
sywac.string('--tag', {
2832
defaultValue: null,
2933
desc: 'Select posts with these tag slugs, inside single quotes. i.e. \'existing-tag, newsletter\''

prompts/add-author.js

+9
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ const choice = {
1414

1515
const options = [
1616
...ghostAPICreds,
17+
{
18+
type: 'list',
19+
name: 'author',
20+
message: 'Current Author:',
21+
pageSize: 20,
22+
choices: function () {
23+
return getAPIAuthorsObj();
24+
}
25+
},
1726
{
1827
type: 'search-checkbox',
1928
name: 'tag',

tasks/add-author.js

+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ const getFullTaskList = (options) => {
5454
try {
5555
let discoveryFilter = [];
5656

57+
if (ctx.args.author) {
58+
discoveryFilter.push(`author:[${ctx.args.author.slug}]`);
59+
}
60+
5761
if (ctx.args.tag && ctx.args.tag.length > 0) {
5862
discoveryFilter.push(`tags:[${transformToCommaString(ctx.args.tag, 'slug')}]`);
5963
}

0 commit comments

Comments
 (0)