Question: I am new to python manipulation of strings.
I have a collection of strings that have a similar format, two examples of the strings are as follows, ex1: "Graduated in 2015", ex2: "Graduates in 2022". The portion of these strings that I would like to extract are the years that is the string that is the last string without spaces. Using the above examples I would like to have an output of something like '2015' and '2020' and save these to a list. Is there a way to extract a substring using this criteria and save these to a list?

visually this is what I want

```
str1<-"Graduated in 2015" 
str2<-"Graduates in 2022"
#some code extracting the year substring and adding them to a list l
print(l)
['2015','2022']

```

Answer: 
Yes, you can use dependency injection into the constructor of CLI commands.

You can check on some Magento native CLIs.
Example `php bin/magento store:list`, you can check on `Magento\Store\Console\Command\StoreListCommand`. They injected storeManager into the constructor to use it like normally
I found out the constructor dependencies were cached in the `generated` (M2.4.1) directory, which had to be manually removed for the DI to work properly. Other than that, following <https://devdocs.magento.com/guides/v2.4/extension-dev-guide/cli-cmds/cli-howto.html> works.