|
14 | 14 |
|
15 | 15 | require_once 'vendor/autoload.php'; |
16 | 16 |
|
17 | | -define("_BC_VERSION", "1.0.3"); |
| 17 | +define("_BC_VERSION", "1.0.4"); |
18 | 18 |
|
19 | 19 | # permission to set to barcode files |
20 | 20 | define("_BC_PERMISSION", 0644); |
|
80 | 80 | sort($formats_list); |
81 | 81 |
|
82 | 82 |
|
| 83 | +function isEncoding($enc=null) { |
| 84 | + global $encodings_list; |
| 85 | + return in_array(strtoupper($enc), $encodings_list); |
| 86 | +} |
| 87 | + |
| 88 | +function isFormat($format=null) { |
| 89 | + global $formats_list; |
| 90 | + return in_array(strtoupper($format), $formats_list); |
| 91 | +} |
| 92 | + |
83 | 93 | /////////////////// GETOPT STARTS |
84 | 94 |
|
85 | 95 | use Ulrichsg\Getopt\Getopt; |
|
90 | 100 | $getopt = new Getopt(array( |
91 | 101 | (new Option('e', 'encoding', Getopt::REQUIRED_ARGUMENT)) |
92 | 102 | ->setDescription('Barcode encoding type selection') |
93 | | - ->setValidation(function($value) { |
94 | | - global $encodings_list; |
95 | | - return in_array(strtoupper($value), $encodings_list); |
96 | | - }) |
97 | | - ->setArgument(new Argument(null, null, 'bar-type')), |
| 103 | + ->setArgument(new Argument(null, 'isEncoding', 'bar-type')), |
98 | 104 | (new Option('f', 'format', Getopt::REQUIRED_ARGUMENT)) |
99 | 105 | ->setDescription('Output format for the barcode') |
100 | | - ->setValidation(function($value, $formats_list) { |
101 | | - global $formats_list; |
102 | | - return in_array(strtoupper($value), $formats_list); |
103 | | - }) |
104 | | - ->setArgument(new Argument(null, null, 'file-type')), |
| 106 | + ->setArgument(new Argument(null, 'isFormat', 'file-type')), |
105 | 107 | (new Option('w', 'width', Getopt::REQUIRED_ARGUMENT)) |
106 | 108 | ->setDescription('Width factor for bars to make wider, defaults to 2') |
107 | 109 | ->setArgument(new Argument(2, 'is_numeric', 'points')), |
|
0 commit comments