How to use the alfy.matches 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 / src / cmd / del.js View on Github external
const outputVariables = pattern => {
	if (!pattern) {
		pattern = ''
	}

	const vars = Object.keys(config.decks.delete)

	const mapper = key => ({
		title: key,
		subtitle: `current deck is ⇒ ${alfy.config.get('default-deck')} | ↵ choose this or pick out another`,
		valid: false,
		autocomplete: `!del ${key} `,
		icon: {path: './icons/delete.png'}
	})

	const out = alfy.matches(pattern, Object.keys(config.decks.delete)).map(mapper)

	return out.length === 0 ? vars.map(mapper) : out
}
github bikenik / alfred-anki / src / cmd / models.js View on Github external
if (!pattern) {
		pattern = ''
	}

	const vars = Object.keys(config.models)

	const mapper = key => ({
		title: `${key}${
			Object.keys(alfy.config.get(key))[0] === undefined ? config.models['default-model'] : Object.keys(alfy.config.get(key))[0]}`,
		subtitle: '↵ pick out another model...',
		valid: false,
		autocomplete: `!model ${key} `,
		icon: {path: './icons/Model.png'}
	})

	const out = alfy.matches(pattern, Object.keys(config.models)).map(mapper)

	return out.length === 0 ? vars.map(mapper) : out
}
github bikenik / alfred-anki / src / cmd / reset.js View on Github external
const outputVariables = pattern => {
	if (!pattern) pattern = ''

	const vars = Object.keys(config.reset)

	const mapper = key => ({
		title: key,
		subtitle: pattern === '' ? 'Hit ↵ to reset all previous settings' : 'hold on...',
		valid: false,
		autocomplete: '!reset reseting... ',
		icon: {path: './icons/Reset.png'}
	})

	const out = alfy.matches(pattern, Object.keys(config.reset)).map(mapper)

	return out.length === 0 ? vars.map(mapper) : out
}
github bikenik / alfred-reverso / src / cmd / set.js View on Github external
if (!pattern) {
		pattern = ''
	}

	const vars = Object.keys(config.decks.defaults)

	const mapper = key => ({
		title: `${key}${
			alfy.config.get(key) === undefined ? config.decks.defaults['default-deck'] : alfy.config.get(key)}`,
		subtitle: '↵ pick out another ...',
		valid: false,
		autocomplete: `!set ${key} `,
		icon: {path: './icons/settings.png'}
	})

	const out = alfy.matches(pattern, Object.keys(config.decks.defaults)).map(mapper)

	return out.length === 0 ? vars.map(mapper) : out
}
github bikenik / alfred-anki / src / cmd / theme.js View on Github external
const outputVariables = pattern => {
	if (!pattern) {
		pattern = ''
	}

	const vars = Object.keys(config.refresh)

	const mapper = key => ({
		title: key,
		subtitle: pattern === '' ? 'Hit ↵ to toogle current theme dark / light' : 'hold on...',
		valid: false,
		autocomplete: '!theme toogle... ',
		icon: {path: './icons/night_and_day.png'}
	})

	const out = alfy.matches(pattern, Object.keys(config.theme)).map(mapper)

	return out.length === 0 ? vars.map(mapper) : out
}
github bikenik / alfred-reverso / src / cmd / refresh.js View on Github external
const outputVariables = pattern => {
	if (!pattern) {
		pattern = ''
	}

	const vars = Object.keys(config.decks.refresh)

	const mapper = key => ({
		title: key,
		subtitle: pattern === '' ? 'Hit ↵ to refresh cards in decks | It will take a few seconds' : 'hold on, your collection will be update',
		valid: false,
		autocomplete: '!refresh refreshing... ',
		icon: {path: './icons/refresh.png'}
	})

	const out = alfy.matches(pattern, Object.keys(config.decks.refresh)).map(mapper)

	return out.length === 0 ? vars.map(mapper) : out
}
github nikersify / alfred-polyglot / lib / output / languages.js View on Github external
module.exports = (pattern, autocomplete = () => undefined) => {
	if (!pattern) {
		pattern = ''
	}

	const out = alfy.matches(pattern, langNames)
		.map(name => ({
			title: name.slice(0, 1).toUpperCase() + name.slice(1),
			autocomplete: autocomplete(name),
			valid: false,
			icon: {
				path: `icons/${languages.getCode(name)}.png`
			}
		}))

	return out.length === 0 ? null : out
}
github bikenik / alfred-anki / src / cmd / profiles.js View on Github external
if (!pattern) {
		pattern = ''
	}

	const vars = Object.keys(config.profiles)

	const mapper = key => ({
		title: `${key}${
			alfy.config.get(key) === undefined ? config.profiles['default-profile'] : alfy.config.get(key)}`,
		subtitle: '↵ pick out another profile...',
		valid: false,
		autocomplete: `!profile ${key} `,
		icon: {path: './icons/Profile.png'}
	})

	const out = alfy.matches(pattern, Object.keys(config.profiles)).map(mapper)

	return out.length === 0 ? vars.map(mapper) : out
}
github bikenik / alfred-anki / src / cmd / del.js View on Github external
const outputVariables = pattern => {
	if (!pattern) {
		pattern = ''
	}

	const vars = Object.keys(config.delete)

	const mapper = key => ({
		title: key,
		subtitle: `current deck is ⇒ ${alfy.config.get('default-deck')} | ↵ choose this or pick out another`,
		valid: false,
		autocomplete: `!del ${key} `,
		icon: {path: './icons/delete.png'}
	})

	const out = alfy.matches(pattern, Object.keys(config.delete)).map(mapper)

	return out.length === 0 ? vars.map(mapper) : out
}