Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
}
// No matches, show all commands
if (/!.*/.test(input)) {
const options = commands.map(command => ({
title: command.meta.name,
subtitle: `${command.meta.help} | Usage: ${command.meta.usage}`,
autocomplete: command.meta.autocomplete,
text: {
largetype: `${command.meta.help} | Usage: ${command.meta.usage}`
},
icon: command.meta.icon,
valid: false
}))
return alfy.inputMatches(options, 'title')
}
if (input === '') {
const ankiModelExist = await modelExist()
if (ankiModelExist.message) {
throw new WorkflowError('Decks was not found, check your Anki profile', errorAction('modelExist'))
}
const ankiDecks = await decks()
if (ankiDecks === null) {
throw new WorkflowError('Decks was not found, check your Anki profile', errorAction('profile'))
}
jsonfile.writeFile(fileAnkiDecks, ankiDecks, {
spaces: 2
}, err => {
}).then(result => {
const data = result.data;
// Remove tasks with the same title
const sortedData = uniqBy(data, 'title');
var task = inputMatches(
sortedData.map(t => {
const project = t.project.title;
return {
title: t.title,
subtitle: `Project: ${project}`,
autocomplete: t.title,
arg: t.title,
variables: {
project: project
}
};
}), 'title');
if (input.length !== 0) {
task.unshift({title: `Create Task: "${input}"`, arg: input});
}
return {
title: x.title,
autocomplete: x.title,
subtitle: `${x.barrel} - ${x.docType}`,
arg: url,
quicklookurl: url,
icon: TYPES.indexOf(x.docType) !== -1 && {path: `./icons/${x.docType}.png`},
mods: {
alt: {
subtitle: x.stability
}
}
};
});
return alfy.inputMatches(items, 'title');
});
).then(res => {
return `${res}°C`;
})
}, {
title: 'Time remaining',
subtitle: () => osxBattery().then(res => {
if (res.isCharging) {
return 'Your computer is charging';
}
return `${res.timeRemaining} minutes left`;
})
}
];
Promise.all(alfy.inputMatches(list, 'title').map(x => x.subtitle().then(y => ({
title: x.title,
subtitle: y
})))).then(res => {
alfy.output(res);
});
'use strict';
const alfy = require('alfy');
const builtinModules = require('builtin-modules/static');
const items = builtinModules.map(module => {
const url = `https://nodejs.org/api/${module}.html`;
return {
title: module,
autocomplete: module,
arg: url,
quicklookurl: url
};
});
alfy.output(alfy.inputMatches(items, 'title'));
teamService.load().then(({ values }) => {
users = teams.concat(teamService.output(users.concat(values)));
alfy.output(alfy.inputMatches(users, 'title'));
});
});
module.exports.fields = async () => {
let result
await getProfileName()
const ankiInfoRes = await ankiInfo()
const fields = await handleFields()
fields.unshift(ankiInfoRes[0] ? ankiInfoRes[0] : ankiInfoRes)
if (fields && fields[0] && fields[0].subtitle && fields[0].name === 'intro') {
result = alfy.inputMatches(fields, 'subtitle')
} else {
result = await ankiInfo()
}
return result
}
const alfy = require('alfy');
const alfredNotifier = require('alfred-notifier');
const languages = [{
title: 'json',
arg: 'json',
}, {
title: 'xml',
arg: 'xml',
}]
const output = alfy.inputMatches(languages, 'title');
alfredNotifier();
alfy.output(output);
return psList().then(data => alfy.inputMatches(data, 'name'));
};
const showTags = async () => {
const tags = await getTags()
tags.unshift('')
const items = []
for (const tag of tags) {
const item = new Render('tags',
'title', 'subtitle', 'arg', 'icon')
item.title = tag
item.subtitle = 'some subtitle'
item.arg = JSON.stringify({Tag: tag})
item.icon = './icons/tag.png'
items.push(item.getProperties())
}
if (alfy.inputMatches(items, 'title').length > 0) {
alfy.output(alfy.inputMatches(items, 'title'))
} else {
const tag = alfy.input.replaceAll(/\s/, '_').replaceAll(/,/, ' ').replaceAll(/\s_/, ' ')
alfy.output([{
title: `Add - [${tag}] - as your new tag`,
subtitle: 'add <, > for several tags',
arg: JSON.stringify({Tag: tag})
}])
}
}