1: | <?php declare(strict_types=1); |
2: | |
3: | namespace Salient\Contract\Cli; |
4: | |
5: | use Salient\Contract\Cli\CliHelpStyleInterface as CliHelpStyle; |
6: | use Salient\Contract\Container\HasContainer; |
7: | use Salient\Contract\Core\HasDescription; |
8: | use Salient\Contract\Core\HasName; |
9: | use LogicException; |
10: | |
11: | /** |
12: | * A node in a CLI command tree |
13: | * |
14: | * @api |
15: | */ |
16: | interface CliCommandNodeInterface extends HasContainer, HasName, HasDescription |
17: | { |
18: | /** |
19: | * Get the command's service container |
20: | */ |
21: | public function getContainer(): CliApplicationInterface; |
22: | |
23: | /** |
24: | * Get the command name as a string of space-delimited subcommands |
25: | * |
26: | * Returns an empty string if {@see CliCommandNodeInterface::setName()} has |
27: | * not been called, or if an empty array of subcommands was passed to |
28: | * {@see CliCommandNodeInterface::setName()}. |
29: | */ |
30: | public function getName(): string; |
31: | |
32: | /** |
33: | * Get the command name as an array of subcommands |
34: | * |
35: | * @return string[] |
36: | */ |
37: | public function getNameParts(): array; |
38: | |
39: | /** |
40: | * Get a one-line description of the command |
41: | */ |
42: | public function getDescription(): string; |
43: | |
44: | /** |
45: | * Called immediately after instantiation by a CliApplicationInterface |
46: | * |
47: | * @param string[] $name |
48: | * @throws LogicException if called more than once per instance. |
49: | */ |
50: | public function setName(array $name): void; |
51: | |
52: | /** |
53: | * Get a one-line summary of the command's options |
54: | * |
55: | * Returns a space-delimited string that includes the name of the command, |
56: | * and the name used to run the script. |
57: | */ |
58: | public function getSynopsis(?CliHelpStyle $style = null): string; |
59: | |
60: | /** |
61: | * Get a detailed explanation of the command |
62: | * |
63: | * @return array<CliHelpSectionName::*|string,string> An array that maps |
64: | * help section names to content. |
65: | */ |
66: | public function getHelp(?CliHelpStyle $style = null): array; |
67: | } |
68: |