Every morning, Gorm takes the inventory with a scroll in hand, copying the menu out dish by dish. He would like to type one command and see everything at once: the dishes, their category, their price and the portions left.
Console commands
A command is a class marked #[AsCommand], whose __invoke() method does the work. Like a controller, it receives its services through autowiring. Its options and arguments are declared directly as parameters of __invoke().
SymfonyStyle ($io) gives a neat, consistent output: title(), table(), success(), warning(), error()…
A command returns an exit code: Command::SUCCESS (0), Command::FAILURE (1) or Command::INVALID (2). A script, a scheduled task or the CI rely on it to know whether everything went well.
Your mission
Write app:inventaire (the inventory):
- a title, “Menu inventory”, then a table with the columns Dish, Category, Price (
12.50 gp) and Portions; - in menu order: categories by position, then from cheapest to most expensive;
- the
--categorie=Drinksoption (categorie= category) shows a single category; - an unknown category makes the command fail, with
The category "Desserts" does not exist.; - a final summary:
5 dishes on the menu.(1 dishin the singular), orThe menu is empty.if there is nothing.
Try it in the Console tab: app:inventaire, then app:inventaire --categorie=Drinks.