瀏覽代碼

v1.0.4 Fix bad format and bad encoding cli opt parsing

master
Gustavo Neves 8 年之前
父節點
當前提交
54dc87fdaf
共有 1 個檔案被更改,包括 13 行新增11 行删除
  1. +13
    -11
      barcode.php

+ 13
- 11
barcode.php 查看文件

@@ -14,7 +14,7 @@

require_once 'vendor/autoload.php';

define("_BC_VERSION", "1.0.3");
define("_BC_VERSION", "1.0.4");

# permission to set to barcode files
define("_BC_PERMISSION", 0644);
@@ -80,6 +80,16 @@ $formats_list = array(
sort($formats_list);


function isEncoding($enc=null) {
global $encodings_list;
return in_array(strtoupper($enc), $encodings_list);
}

function isFormat($format=null) {
global $formats_list;
return in_array(strtoupper($format), $formats_list);
}

/////////////////// GETOPT STARTS

use Ulrichsg\Getopt\Getopt;
@@ -90,18 +100,10 @@ use Ulrichsg\Getopt\Argument;
$getopt = new Getopt(array(
(new Option('e', 'encoding', Getopt::REQUIRED_ARGUMENT))
->setDescription('Barcode encoding type selection')
->setValidation(function($value) {
global $encodings_list;
return in_array(strtoupper($value), $encodings_list);
})
->setArgument(new Argument(null, null, 'bar-type')),
->setArgument(new Argument(null, 'isEncoding', 'bar-type')),
(new Option('f', 'format', Getopt::REQUIRED_ARGUMENT))
->setDescription('Output format for the barcode')
->setValidation(function($value, $formats_list) {
global $formats_list;
return in_array(strtoupper($value), $formats_list);
})
->setArgument(new Argument(null, null, 'file-type')),
->setArgument(new Argument(null, 'isFormat', 'file-type')),
(new Option('w', 'width', Getopt::REQUIRED_ARGUMENT))
->setDescription('Width factor for bars to make wider, defaults to 2')
->setArgument(new Argument(2, 'is_numeric', 'points')),


Loading…
取消
儲存