Skip to content

Commit d3bfd38

Browse files
committed
add trait tool class
1 parent c4bb8e6 commit d3bfd38

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

src/AbstractCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace inhere\console;
1010

1111
use inhere\console\utils\TraitInputOutput;
12+
use inhere\console\utils\TraitInteract;
1213

1314
/**
1415
* Class AbstractCommand
@@ -17,6 +18,7 @@
1718
abstract class AbstractCommand
1819
{
1920
use TraitInputOutput;
21+
use TraitInteract;
2022

2123
// command description message
2224
// please use the const setting current controller/command description

src/utils/TraitInteract.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: inhere
5+
* Date: 2017-03-17
6+
* Time: 11:38
7+
*/
8+
9+
namespace inhere\console\utils;
10+
11+
/**
12+
* Class TraitInteract
13+
* @package inhere\console\utils
14+
*/
15+
trait TraitInteract
16+
{
17+
/**
18+
* @inheritdoc
19+
* @see Interact::choice()
20+
*/
21+
public function select($description, $options, $default = null, $allowExit=true)
22+
{
23+
return self::choice($description, $options, $default, $allowExit);
24+
}
25+
public function choice($description, $options, $default = null, $allowExit=true)
26+
{
27+
return Interact::choice($description, $options, $default, $allowExit);
28+
}
29+
30+
/**
31+
* @inheritdoc
32+
* @see Interact::confirm()
33+
*/
34+
public function confirm($question, $default = true)
35+
{
36+
return Interact::confirm($question, $default);
37+
}
38+
39+
/**
40+
* @inheritdoc
41+
* @see Interact::question()
42+
*/
43+
public function ask($question, $default = null, \Closure $validator = null)
44+
{
45+
return self::question($question, $default, $validator);
46+
}
47+
public function question($question, $default = null, \Closure $validator = null)
48+
{
49+
return Interact::question($question, $default, $validator);
50+
}
51+
52+
/**
53+
* @inheritdoc
54+
* @see Interact::loopAsk()
55+
*/
56+
public function loopAsk($question, $default = null, \Closure $validator = null, $times=3)
57+
{
58+
return Interact::loopAsk($question, $default, $validator, $times);
59+
}
60+
61+
}

0 commit comments

Comments
 (0)