<?php require_once 'vendor/autoload.php'; use GetOptionKit\GetOptionKit; $getopt = new GetOptionKit(); $getopt->add('n|number:=i', 'option requires a integer value'); try { $result = $getopt->parse($argv); $number = $result->number ? $result->number : 10; } catch (Exception $e) { echo 'Try: create.php --number=10'; exit; } $seedFile = 'seed.csv'; $reader = new Csv_Reader($seedFile, new Csv_Dialect()); $headerRow = $reader->getAssociativeRow(); $seedRow = $reader->getAssociativeRow(); $writer = new Csv_Writer(STDOUT, new Csv_Dialect(array('quoting' => Csv_Dialect::QUOTE_ALL))); $writer->writeRow($headerRow); for ($i = 1; $i <= $number; $i++) { $productRow = array_merge($seedRow, array('sku' => 'sku-' . $i, 'name' => 'product ' . $i)); $writer->writeRow($productRow); }
#!/usr/bin/env php <?php /* * This file is part of the GetOptionKit package. * * (c) Yo-An Lin <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * */ require 'Universal/ClassLoader/SplClassLoader.php'; $classLoader = new Universal\ClassLoader\SplClassLoader(array('GetOptionKit' => 'src')); $classLoader->register(); use GetOptionKit\GetOptionKit; $opt = new GetOptionKit(); $opt->add('f|foo:', 'option requires a value.'); $opt->add('b|bar+', 'option with multiple value.'); $opt->add('z|zoo?', 'option with optional value.'); $opt->add('v|verbose', 'verbose message.'); $opt->add('d|debug', 'debug message.'); $opt->add('long', 'long option name only.'); $opt->add('s', 'short option name only.'); $opt->specs->printOptions(); echo "Enabled options: \n"; try { $result = $opt->parse($argv); foreach ($result as $key => $spec) { echo $spec . "\n"; } } catch (Exception $e) {