1111interface ICliApplication extends IApplication
1212{
1313 /**
14- * Get the command started from the command line
14+ * Get the command invoked by run()
15+ *
16+ * This method should only return a command that is currently running.
1517 */
1618 public function getRunningCommand (): ?ICliCommand ;
1719
20+ /**
21+ * Get the command most recently invoked by run()
22+ *
23+ * This method should only return a command that ran to completion or failed
24+ * with an exception.
25+ */
26+ public function getLastCommand (): ?ICliCommand ;
27+
1828 /**
1929 * Get the return value most recently recorded by run()
2030 *
21- * Returns `0` if {@see ICliApplication::run()} has not recorded a return
22- * value.
31+ * This method should return `0` if a return value has not been recorded.
2332 */
2433 public function getLastExitStatus (): int ;
2534
2635 /**
2736 * Register a command with the container
2837 *
2938 * @param string[] $name The name of the command as an array of subcommands.
30- *
3139 * Valid subcommands start with a letter, followed by any number of letters,
3240 * numbers, hyphens and underscores.
33- * @param class-string<ICliCommand> $id The name of the class to register.
41+ * @param class-string<ICliCommand> $id
3442 * @return $this
3543 * @throws LogicException if `$name` is invalid or conflicts with a
3644 * registered command.
3745 */
3846 public function command (array $ name , string $ id );
3947
4048 /**
41- * Register one, and only one, ICliCommand for the lifetime of the container
49+ * Register one, and only one, command for the lifetime of the container
4250 *
43- * The command is registered with an empty name, placing it at the root of
44- * the container's subcommand tree .
51+ * Calling this method should have the same effect as calling
52+ * {@see ICliApplication::command()} with an empty command name .
4553 *
46- * @param class-string<ICliCommand> $id The name of the class to register.
54+ * @param class-string<ICliCommand> $id
4755 * @return $this
4856 * @throws LogicException if another command has already been registered.
49- *
50- * @see ICliApplication::command()
5157 */
5258 public function oneCommand (string $ id );
5359
5460 /**
5561 * Process command line arguments passed to the script and record a return
5662 * value
5763 *
58- * The first applicable action is taken :
64+ * This method should take the first applicable action:
5965 *
6066 * - If `--help` is the only remaining argument after processing subcommand
61- * arguments, a help message is printed to `STDOUT` and the return value
62- * is `0`.
63- * - If `--version` is the only remaining argument, the application's name
64- * and version number is printed to `STDOUT` and the return value is `0`.
65- * - If subcommand arguments resolve to a registered command, it is invoked
66- * and the return value is its exit status.
67+ * arguments, print a help message to `STDOUT`. Return value: `0`
68+ *
69+ * - If `--version` is the only remaining argument, print the application's
70+ * name and version number to `STDOUT`. Return value: `0`
71+ *
72+ * - If subcommand arguments resolve to a registered command, create an
73+ * instance of the command and run it. Return value: command exit status
74+ *
6775 * - If, after processing subcommand arguments, there are no further
68- * arguments but there are further subcommands, a one-line synopsis of
69- * each registered subcommand is printed and the return value is `0`.
76+ * arguments but there are further subcommands, print a one-line synopsis
77+ * of each registered subcommand. Return value: `0`
7078 *
71- * Otherwise, an error is reported, a one-line synopsis of each registered
72- * subcommand is printed, and the return value is `1`.
79+ * - Report an error and print a one-line synopsis of each registered
80+ * subcommand. Return value: `1`
7381 *
7482 * @return $this
7583 */
@@ -78,18 +86,18 @@ public function run();
7886 /**
7987 * Exit with the return value most recently recorded by run()
8088 *
81- * The exit status is `0` if {@see ICliApplication::run()} has not recorded
82- * a return value .
89+ * This method should use exit status `0` if a return value has not been
90+ * recorded .
8391 *
8492 * @return never
8593 */
8694 public function exit ();
8795
8896 /**
89- * Exit after processing command line arguments passed to the script
97+ * Process command line arguments passed to the script and exit with the
98+ * recorded return value
9099 *
91- * The return value recorded by {@see ICliApplication::run()} is used as the
92- * exit status.
100+ * See {@see ICliApplication::run()} for details.
93101 *
94102 * @return never
95103 */
0 commit comments