-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoverLetterModifier.php
More file actions
47 lines (38 loc) · 1.13 KB
/
Copy pathCoverLetterModifier.php
File metadata and controls
47 lines (38 loc) · 1.13 KB
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
/**
* PHP CLI for modifying cover letters.
*
* @author Nicholas Sabelli
*/
require_once("Modifier.php");
$template = null;
$company = null;
$position = null;
if ($argc == 1) {
$exists = false;
do {
fwrite(STDOUT, "Enter template file path: ");
$template = trim(trim(fgets(STDIN)), "\'\"");
if(!$exists = file_exists($template)) {
fwrite(STDOUT, "File not found.\n");
}
} while (!$exists);
fwrite(STDOUT, "Enter company name: ");
$company = trim(trim(fgets(STDIN)), "\'\"");
fwrite(STDOUT, "Enter position title: ");
$position = trim(trim(fgets(STDIN)), "\'\"");
} elseif ($argc == 4) {
$template = $argv[1];
$company = $argv[2];
$position = $argv[3];
} elseif ($argc > 4) {
fwrite(STDOUT, "Error: Too many arguments. Expected 3 (template file path, company, position).\n");
exit(1);
} elseif ($argc < 4) {
fwrite(STDOUT, "Error: Too few arguments. Expected 3 (template file path, company, position).\n");
exit(1);
}
$modifier = new Modifier($template, $company, $position);
fwrite(STDOUT, "File created!\n");
exit();
?>