@@ -33,31 +33,169 @@ return function (Skeletor $skeletor) {
3333};
3434```
3535
36- ### Available methods on ` Skeletor::class ` :
37-
38- - ` text(string $label, string $placeholder = '', string $default = '', bool|string $required = false, mixed $validate = null, string $hint = '', ?Closure $transform = null): string `
39- - ` textarea(string $label, string $placeholder = '', string $default = '', bool|string $required = false, mixed $validate = null, string $hint = '', int $rows = 5, ?Closure $transform = null): string `
40- - ` password(string $label, string $placeholder = '', bool|string $required = false, mixed $validate = null, string $hint = '', ?Closure $transform = null): string `
41- - ` confirm(string $label, bool $default = true, string $yes = 'Yes', string $no = 'No', bool|string $required = false, mixed $validate = null, string $hint = '', ?Closure $transform = null): bool `
42- - ` select(string $label, array|Collection $options, int|string|null $default = null, int $scroll = 5, mixed $validate = null, string $hint = '', bool|string $required = true, ?Closure $transform = null): int|string `
43- - ` multiselect(string $label, array|Collection $options, array|Collection $default = [], int $scroll = 5, bool|string $required = false, mixed $validate = null, string $hint = 'Use the space bar to select options.', ?Closure $transform = null): array `
44- - ` suggest(string $label, array|Collection|Closure $options, string $placeholder = '', string $default = '', int $scroll = 5, bool|string $required = false, mixed $validate = null, string $hint = '', ?Closure $transform = null): string `
45- - ` search(string $label, Closure $options, string $placeholder = '', int $scroll = 5, mixed $validate = null, string $hint = '', bool|string $required = true, ?Closure $transform = null): int|string `
46- - ` multisearch(string $label, Closure $options, string $placeholder = '', int $scroll = 5, bool|string $required = false, mixed $validate = null, string $hint = 'Use the space bar to select options.', ?Closure $transform = null): array `
47- - ` pause(string $message = 'Press enter to continue...'): bool `
48- - ` table(array|Collection $headers = [], array|Collection|null $rows = null): void `
49- - ` spin(string $message = '', Closure $callback = null): mixed `
50- - ` progress(string $label, iterable|int $steps, ?Closure $callback = null, string $hint = ''): array|Progress `
51- - ` info(string $message): void `
52- - ` alert(string $message): void `
53- - ` warning(string $message): void `
54- - ` error(string $message): void `
55- - ` intro(string $message): void `
56- - ` outro(string $message): void `
57- - ` exec(array $command, ?string $cwd = null, ?array $env = null, mixed $input = null, ?float $timeout = 60, ?callable $callback = null): Process `
58- - ` readFile(string $filename): string `
59- - ` writeFile(string $filename, string $data): bool|int `
60- - ` removeFile(string $filename): bool `
61- - ` removeDirectory(string $filename): bool `
62- - ` exists(string $filename): bool `
63- - ` updateComposerJson(array $data): bool|int `
36+ ## Available Methods
37+
38+ ### Gathering User Input
39+
40+ #### Text Input
41+
42+ ``` php
43+ $text = $skeletor->text('Enter your name:', 'John Doe');
44+ ```
45+
46+ #### Textarea Input
47+
48+ ``` php
49+ $description = $skeletor->textarea('Enter a description:');
50+ ```
51+
52+ #### Password Input
53+
54+ ``` php
55+ $password = $skeletor->password('Enter your password:');
56+ ```
57+
58+ #### Confirm
59+
60+ ``` php
61+ $confirmed = $skeletor->confirm('Do you agree?', true);
62+ ```
63+
64+ #### Select
65+
66+ ``` php
67+ $choice = $skeletor->select('Choose an option:', ['Option 1', 'Option 2', 'Option 3']);
68+ ```
69+
70+ #### Multiselect
71+
72+ ``` php
73+ $choices = $skeletor->multiselect('Choose multiple options:', ['Option 1', 'Option 2', 'Option 3']);
74+ ```
75+
76+ #### Suggest
77+
78+ ``` php
79+ $suggestion = $skeletor->suggest('Start typing:', ['Suggestion 1', 'Suggestion 2', 'Suggestion 3']);
80+ ```
81+
82+ #### Search
83+
84+ ``` php
85+ $searchResult = $skeletor->search('Search for an option:', function ($query) {
86+ return ['Result 1', 'Result 2', 'Result 3'];
87+ });
88+ ```
89+
90+ #### Multisearch
91+
92+ ``` php
93+ $searchResults = $skeletor->multisearch('Search for multiple options:', function ($query) {
94+ return ['Result 1', 'Result 2', 'Result 3'];
95+ });
96+ ```
97+
98+ ### Displaying Information
99+
100+ #### Spinner
101+
102+ ``` php
103+ $result = $skeletor->spin('Processing...', function () {
104+ // long running task
105+ return true;
106+ });
107+ ```
108+
109+ #### Progress Bar
110+
111+ ``` php
112+ $progress = $skeletor->progress('Processing items...', 100, function ($progress) {
113+ for ($i = 0; $i < 100; $i++) {
114+ $progress->advance();
115+ }
116+ });
117+ ```
118+
119+ #### Messages
120+
121+ ``` php
122+ $skeletor->info('This is an info message.');
123+
124+ $skeletor->alert('This is an alert message.');
125+
126+ $skeletor->warning('This is a warning message.');
127+
128+ $skeletor->error('This is an error message.');
129+
130+ $skeletor->intro('Welcome to the setup wizard.');
131+
132+ $skeletor->outro('Setup complete.');
133+ ```
134+
135+ ### File Operations
136+
137+ #### Reading a File
138+
139+ ``` php
140+ $content = $skeletor->readFile('path/to/file.txt');
141+ ```
142+
143+ #### Writing to a File
144+
145+ ``` php
146+ $bytesWritten = $skeletor->writeFile('path/to/file.txt', 'New content');
147+ ```
148+
149+ #### Removing a File
150+
151+ ``` php
152+ $success = $skeletor->removeFile('path/to/file.txt');
153+ ```
154+
155+ #### Removing a Directory
156+
157+ ``` php
158+ $success = $skeletor->removeDirectory('path/to/directory');
159+ ```
160+
161+ #### Checking if a File Exists
162+
163+ ``` php
164+ $exists = $skeletor->exists('path/to/file.txt');
165+ ```
166+
167+ #### Updating composer.json
168+
169+ ``` php
170+ $bytesWritten = $skeletor->updateComposerJson(['require' => ['new/package' => '^1.0']]);
171+ ```
172+
173+ #### Executing a Command
174+
175+ ``` php
176+ $process = $skeletor->exec(['ls', '-la']);
177+ ```
178+
179+ #### Table
180+
181+ ``` php
182+ $skeletor->table(['Header 1', 'Header 2'], [['Row 1 Col 1', 'Row 1 Col 2'], ['Row 2 Col 1', 'Row 2 Col 2']]);
183+ ```
184+
185+ #### Pause
186+
187+ ``` php
188+ $skeletor->pause(5);
189+ ```
190+
191+ #### Replace In File
192+
193+ ``` php
194+ $replacements = $skeletor->replaceInFile('path/to/file.txt', 'search string', 'replace string');
195+ ```
196+
197+ #### Preg Replace In File
198+
199+ ``` php
200+ $replacements = $skeletor->pregReplaceInFile('path/to/file.txt', '/pattern/', 'replace string');
201+ ```
0 commit comments