-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
loremipsum.php
47 lines (35 loc) · 964 Bytes
/
loremipsum.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
use joshtronic\LoremIpsum;
use Alfred\Workflows\Workflow;
require __DIR__ . '/vendor/autoload.php';
$lipsum = new LoremIpsum;
$workflow = new Workflow;
$type = $argv[1];
$count = trim($argv[2]);
if ($count === '') {
switch ($type) {
case 'words': $count = 7; break;
case 'sentences': $count = 3; break;
case 'paragraphs': $count = 3; break;
}
}
if (! ctype_digit((string) $count)) {
$workflow->result()
->title('Invalid Number')
->icon('error.png')
->valid(false);
echo $workflow->output();
exit;
}
$lipsum->words(1); // avoid starting with `Lorem`
$arg = ucfirst($lipsum->{$type}($count));
$noun = $count > 1 ? $type : substr($type, 0, -1);
$workflow->result()
->uid('lorem-words')
->title(ucfirst($type))
->subtitle("Generate {$count} {$noun}...")
->arg($arg)
->text('copy', $arg)
->text('largetype', $arg)
->valid(true);
echo $workflow->output();