Skip to content

Commit 8242dd8

Browse files
committed
Add status filter to add-tags tool
1 parent 83fe84b commit 8242dd8

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

commands/add-tags.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ const setup = (sywac) => {
2424
defaultValue: false,
2525
desc: 'Show verbose output'
2626
});
27+
sywac.enumeration('--status', {
28+
defaultValue: 'all',
29+
choices: ['all', 'draft', 'published'],
30+
desc: 'Post visibility'
31+
});
2732
sywac.array('--type', {
2833
defaultValue: 'all',
2934
choices: ['all', 'posts', 'pages'],

prompts/add-tags.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,25 @@ const choice = {
2626

2727
const options = [
2828
...ghostAPICreds,
29+
{
30+
type: 'list',
31+
name: 'status',
32+
message: 'Status: (Leave blank for all)',
33+
choices: [
34+
{
35+
name: 'All',
36+
value: 'all'
37+
},
38+
{
39+
name: 'Draft',
40+
value: 'draft'
41+
},
42+
{
43+
name: 'Published',
44+
value: 'published'
45+
}
46+
]
47+
},
2948
{
3049
type: 'checkbox',
3150
name: 'type',

tasks/add-tags.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ const getFullTaskList = (options) => {
4949
if (options.customFilter) {
5050
postDiscoveryFilter.push(options.customFilter);
5151
} else {
52+
if (ctx.args.status && ctx.args.status !== 'all') {
53+
postDiscoveryFilter.push(`status:[${ctx.args.status}]`);
54+
}
55+
5256
if (ctx.args.visibility && ctx.args.visibility !== 'all') {
5357
postDiscoveryFilter.push(`visibility:[${ctx.args.visibility}]`);
5458
}

0 commit comments

Comments
 (0)