Re: [pve-devel] [PATCH v1 pve-esxi-import-tools 4/5] listvms: add arg parser, context manager for connections, fetch helper

2024-03-20 Thread Max Carrara
On Wed Mar 20, 2024 at 1:45 PM CET, Wolfgang Bumiller wrote: > On Tue, Mar 19, 2024 at 04:32:49PM +0100, Max Carrara wrote: > > +@contextmanager > > +def connect_to_esxi_host(args: EsxiConnectonArgs) -> vim.ServiceInstance: > > +"""Opens a connection to an ESXi host with the given username and

Re: [pve-devel] [PATCH v1 pve-esxi-import-tools 4/5] listvms: add arg parser, context manager for connections, fetch helper

2024-03-20 Thread Wolfgang Bumiller
On Tue, Mar 19, 2024 at 04:32:49PM +0100, Max Carrara wrote: > +@contextmanager > +def connect_to_esxi_host(args: EsxiConnectonArgs) -> vim.ServiceInstance: > +"""Opens a connection to an ESXi host with the given username and > password > +contained in the password file. > +""" > +

Re: [pve-devel] [PATCH v1 pve-esxi-import-tools 4/5] listvms: add arg parser, context manager for connections, fetch helper

2024-03-20 Thread Max Carrara
On Wed Mar 20, 2024 at 10:39 AM CET, Lukas Wagner wrote: > > > On 2024-03-19 16:32, Max Carrara wrote: > > > +def _squeeze_and_wrap(text: str) -> str: > > +"""Makes it easier to write help text using multiline strings.""" > > + > > +text = text.replace("\n", " ").strip() > > +

Re: [pve-devel] [PATCH v1 pve-esxi-import-tools 4/5] listvms: add arg parser, context manager for connections, fetch helper

2024-03-20 Thread Lukas Wagner
On 2024-03-19 16:32, Max Carrara wrote: > +def _squeeze_and_wrap(text: str) -> str: > +"""Makes it easier to write help text using multiline strings.""" > + > +text = text.replace("\n", " ").strip() > + > +# squeeze recurring spaces > +while " " in text: >

[pve-devel] [PATCH v1 pve-esxi-import-tools 4/5] listvms: add arg parser, context manager for connections, fetch helper

2024-03-19 Thread Max Carrara
In order to make the CLI interface more friendly to humans, Python's `argparse` [0] module from the standard library is used to parse the arguments provided to the script. Each option and positional argument also contain a short help text that is shown when running the script with either "-h" or