1 | <?php |
||
9 | class Vi extends Command |
||
10 | { |
||
11 | /** |
||
12 | * The console command name. |
||
13 | * |
||
14 | * @var string |
||
15 | */ |
||
16 | protected $name = 'vi'; |
||
17 | |||
18 | /** |
||
19 | * The console command description. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $description = 'Vi Editor'; |
||
24 | |||
25 | /** |
||
26 | * $files. |
||
27 | * |
||
28 | * @var \Illuminate\Filesystem\Filesystem |
||
29 | */ |
||
30 | protected $files; |
||
31 | |||
32 | /** |
||
33 | * __construct. |
||
34 | * |
||
35 | * @param \Illuminate\Filesystem\Filesystem $files |
||
36 | */ |
||
37 | 1 | public function __construct(Filesystem $files) |
|
43 | |||
44 | /** |
||
45 | * Handle the command. |
||
46 | * |
||
47 | * @throws \InvalidArgumentException |
||
48 | */ |
||
49 | 1 | public function handle() |
|
50 | { |
||
51 | 1 | $path = $this->argument('path'); |
|
52 | 1 | $text = $this->option('text'); |
|
53 | 1 | $root = function_exists('base_path') === true ? base_path() : getcwd(); |
|
54 | 1 | $path = rtrim($root, '/').'/'.$path; |
|
55 | |||
56 | 1 | if (is_null($text) === false) { |
|
57 | 1 | $this->files->put($path, $text); |
|
58 | } else { |
||
59 | $this->line($this->files->get($path)); |
||
60 | } |
||
61 | 1 | } |
|
62 | |||
63 | /** |
||
64 | * Get the console command arguments. |
||
65 | * |
||
66 | * @return array |
||
67 | */ |
||
68 | 1 | protected function getArguments() |
|
74 | |||
75 | /** |
||
76 | * Get the console command options. |
||
77 | * |
||
78 | * @return array |
||
79 | */ |
||
80 | 1 | protected function getOptions() |
|
86 | } |
||
87 |