How to use the alfy.inputMatches function in alfy

To help you get started, we’ve selected a few alfy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bikenik / alfred-reverso / index.js View on Github external
}
	}

	// 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 => {
github skibitsky / alfred-timing / tasks.js View on Github external
}).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});
	}
github SamVerschueren / alfred-ng / lib / api.js View on Github external
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');
	});
github alonalon / alfred-battery / index.js View on Github external
).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);
});
github SamVerschueren / alfred-node / index.js View on Github external
'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'));
github nicklayb / alfred-bitbucket / teams.js View on Github external
teamService.load().then(({ values }) => {
            users = teams.concat(teamService.output(users.concat(values)));
            alfy.output(alfy.inputMatches(users, 'title'));
        });
    });
github bikenik / alfred-anki / src / wf / index.js View on Github external
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
}
github importre / alfred-tidy / src / index.js View on Github external
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);
github SamVerschueren / alfred-fkill / index.js View on Github external
	return psList().then(data => alfy.inputMatches(data, 'name'));
};
github bikenik / alfred-anki / src / wf / fields.js View on Github external
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})
			}])
		}
	}