@@ -16,22 +16,12 @@ class CLI extends WP_CLI_Command {
1616 /**
1717 * Generate products.
1818 *
19- * ## OPTIONS
20- *
21- * <amount>
22- * : The amount of products to generate
23- * ---
24- * default: 100
25- * ---
26- *
27- * ## EXAMPLES
28- * wc generate products 100
29- *
3019 * @param array $args Arguments specified.
3120 * @param array $assoc_args Associative arguments specified.
3221 */
3322 public static function products ( $ args , $ assoc_args ) {
3423 list ( $ amount ) = $ args ;
24+ $ amount = absint ( $ amount );
3525
3626 $ time_start = microtime ( true );
3727
@@ -59,30 +49,15 @@ public static function products( $args, $assoc_args ) {
5949 /**
6050 * Generate orders.
6151 *
62- * ## OPTIONS
63- *
64- * <amount>
65- * : The amount of orders to generate
66- * ---
67- * default: 100
68- * ---
69- *
70- * ## EXAMPLES
71- * wc generate orders 100
72- *
7352 * @param array $args Arguments specified.
7453 * @param array $assoc_args Associative arguments specified.
7554 */
7655 public static function orders ( $ args , $ assoc_args ) {
7756 list ( $ amount ) = $ args ;
57+ $ amount = absint ( $ amount );
7858
7959 $ time_start = microtime ( true );
8060
81- $ amount = (int ) $ amount ;
82- if ( empty ( $ amount ) ) {
83- $ amount = 100 ;
84- }
85-
8661 if ( ! empty ( $ assoc_args ['status ' ] ) ) {
8762 $ status = $ assoc_args ['status ' ];
8863 if ( ! wc_is_order_status ( 'wc- ' . $ status ) ) {
@@ -111,22 +86,12 @@ public static function orders( $args, $assoc_args ) {
11186 /**
11287 * Generate customers.
11388 *
114- * ## OPTIONS
115- *
116- * <amount>
117- * : The amount of customers to generate
118- * ---
119- * default: 100
120- * ---
121- *
122- * ## EXAMPLES
123- * wc generate customers 100
124- *
12589 * @param array $args Arguments specified.
12690 * @param array $assoc_args Associative arguments specified.
12791 */
12892 public static function customers ( $ args , $ assoc_args ) {
12993 list ( $ amount ) = $ args ;
94+ $ amount = absint ( $ amount );
13095
13196 $ time_start = microtime ( true );
13297
@@ -148,30 +113,15 @@ public static function customers( $args, $assoc_args ) {
148113 /**
149114 * Generate coupons.
150115 *
151- * ## OPTIONS
152- *
153- * <amount>
154- * : The amount of coupons to generate
155- * ---
156- * default: 100
157- * ---
158- *
159- * ## EXAMPLES
160- * wc generate coupons 100
161- *
162116 * @param array $args Arguments specified.
163117 * @param array $assoc_args Associative arguments specified.
164118 */
165119 public static function coupons ( $ args , $ assoc_args ) {
166120 list ( $ amount ) = $ args ;
121+ $ amount = absint ( $ amount );
167122
168123 $ time_start = microtime ( true );
169124
170- $ amount = (int ) $ amount ;
171- if ( empty ( $ amount ) ) {
172- $ amount = 10 ;
173- }
174-
175125 $ min = 5 ;
176126 $ max = 100 ;
177127 if ( ! empty ( $ assoc_args ['min ' ] ) ) {
@@ -257,59 +207,84 @@ function () use ( $progress ) {
257207) );
258208
259209WP_CLI ::add_command ( 'wc generate orders ' , array ( 'WC\SmoothGenerator\CLI ' , 'orders ' ), array (
260- 'synopsis ' => array (
210+ 'shortdesc ' => 'Generate orders. ' ,
211+ 'synopsis ' => array (
261212 array (
262- 'name ' => 'amount ' ,
263- 'type ' => 'positional ' ,
264- 'optional ' => true ,
265- 'default ' => 100 ,
213+ 'name ' => 'amount ' ,
214+ 'type ' => 'positional ' ,
215+ 'description ' => 'The number of orders to generate. ' ,
216+ 'optional ' => true ,
217+ 'default ' => 10 ,
266218 ),
267219 array (
268- 'name ' => 'date-start ' ,
269- 'type ' => 'assoc ' ,
270- 'optional ' => true ,
220+ 'name ' => 'date-start ' ,
221+ 'type ' => 'assoc ' ,
222+ 'description ' => 'Randomize the order date using this as the lower limit. Format as YYYY-MM-DD. ' ,
223+ 'optional ' => true ,
271224 ),
272225 array (
273- 'name ' => 'date-end ' ,
274- 'type ' => 'assoc ' ,
275- 'optional ' => true ,
226+ 'name ' => 'date-end ' ,
227+ 'type ' => 'assoc ' ,
228+ 'description ' => 'Randomize the order date using this as the upper limit. Only works in conjunction with date-start. Format as YYYY-MM-DD. ' ,
229+ 'optional ' => true ,
276230 ),
277231 array (
278- 'name ' => 'status ' ,
279- 'type ' => 'assoc ' ,
280- 'optional ' => true ,
232+ 'name ' => 'status ' ,
233+ 'type ' => 'assoc ' ,
234+ 'description ' => 'Specify one status for all the generated orders. Otherwise defaults to a mix. ' ,
235+ 'optional ' => true ,
236+ 'options ' => array ( 'completed ' , 'processing ' , 'on-hold ' , 'failed ' ),
281237 ),
282238 array (
283- 'name ' => 'coupons ' ,
284- 'type ' => 'assoc ' ,
285- 'optional ' => true ,
239+ 'name ' => 'coupons ' ,
240+ 'type ' => 'flag ' ,
241+ 'description ' => 'Create and apply a coupon to each generated order. ' ,
242+ 'optional ' => true ,
286243 ),
287244 ),
245+ 'longdesc ' => "## EXAMPLES \n\nwc generate orders 10 \n\nwc generate orders 50 --date-start=2020-01-01 --date-end=2022-12-31 --status=completed --coupons " ,
288246) );
289247
290- WP_CLI ::add_command ( 'wc generate customers ' , array ( 'WC\SmoothGenerator\CLI ' , 'customers ' ) );
248+ WP_CLI ::add_command ( 'wc generate customers ' , array ( 'WC\SmoothGenerator\CLI ' , 'customers ' ), array (
249+ 'shortdesc ' => 'Generate customers. ' ,
250+ 'synopsis ' => array (
251+ array (
252+ 'name ' => 'amount ' ,
253+ 'type ' => 'positional ' ,
254+ 'description ' => 'The number of customers to generate. ' ,
255+ 'optional ' => true ,
256+ 'default ' => 10 ,
257+ ),
258+ ),
259+ 'longdesc ' => "## EXAMPLES \n\nwc generate customers 10 " ,
260+ ) );
291261
292262WP_CLI ::add_command ( 'wc generate coupons ' , array ( 'WC\SmoothGenerator\CLI ' , 'coupons ' ), array (
293- 'synopsis ' => array (
263+ 'shortdesc ' => 'Generate coupons. ' ,
264+ 'synopsis ' => array (
294265 array (
295- 'name ' => 'amount ' ,
296- 'type ' => 'positional ' ,
297- 'optional ' => true ,
298- 'default ' => 10 ,
266+ 'name ' => 'amount ' ,
267+ 'type ' => 'positional ' ,
268+ 'description ' => 'The number of coupons to generate. ' ,
269+ 'optional ' => true ,
270+ 'default ' => 10 ,
299271 ),
300272 array (
301- 'name ' => 'min ' ,
302- 'optional ' => true ,
303- 'type ' => 'assoc ' ,
304- 'default ' => 5 ,
273+ 'name ' => 'min ' ,
274+ 'type ' => 'assoc ' ,
275+ 'description ' => 'Specify the minimum discount of each coupon. ' ,
276+ 'optional ' => true ,
277+ 'default ' => 5 ,
305278 ),
306279 array (
307- 'name ' => 'max ' ,
308- 'optional ' => true ,
309- 'type ' => 'assoc ' ,
310- 'default ' => 100 ,
280+ 'name ' => 'max ' ,
281+ 'type ' => 'assoc ' ,
282+ 'description ' => 'Specify the maximum discount of each coupon. ' ,
283+ 'optional ' => true ,
284+ 'default ' => 100 ,
311285 ),
312286 ),
287+ 'longdesc ' => "## EXAMPLES \n\nwc generate coupons 10 \n\nwc generate coupons 50 --min=1 --max=50 " ,
313288) );
314289
315290WP_CLI ::add_command ( 'wc generate terms ' , array ( 'WC\SmoothGenerator\CLI ' , 'terms ' ), array (
@@ -344,5 +319,5 @@ function () use ( $progress ) {
344319 'default ' => 0 ,
345320 ),
346321 ),
347- 'longdesc ' => "## EXAMPLES \n\nwc generate terms product_tag 10 \n\nwc generate terms product_cat 50 --max_depth =3 " ,
322+ 'longdesc ' => "## EXAMPLES \n\nwc generate terms product_tag 10 \n\nwc generate terms product_cat 50 --max-depth =3 " ,
348323) );
0 commit comments