Docker gets error “failed to compute cache key: not found” – runs fine in Visual Studio

Check your .dockerignore file. Possible it ignores needed files for copy command and you get failed to compute cache key error. .dockerignore may be configured to minimize the files sent to docker for performance and security: * !dist/ The first line * disallows all files. The second line !dist/ allows the dist folder This can … Read more

Shared options and flags between commands

I have found a simple solution! I slightly edited the snippet from https://github.com/pallets/click/issues/108 : import click _cmd1_options = [ click.option(‘–cmd1-opt’) ] _cmd2_options = [ click.option(‘–cmd2-opt’) ] def add_options(options): def _add_options(func): for option in reversed(options): func = option(func) return func return _add_options @click.group() def group(**kwargs): pass @group.command() @add_options(_cmd1_options) def cmd1(**kwargs): print(kwargs) @group.command() @add_options(_cmd2_options) def cmd2(**kwargs): print(kwargs) … Read more

Call a click command from code

You can call a click command function from regular code by reconstructing the command line from parameters. Using your example it could look somthing like this: call_click_command(app, width, [… other arguments …]) Code: def call_click_command(cmd, *args, **kwargs): “”” Wrapper to call a click command :param cmd: click cli command function to call :param args: arguments … Read more

What can I do about “WMIC is deprecated”?

As mentioned in comments, WMIC is utility that acts as interface to communication with WMI. It’s not WMI itself that is being deprecated, but “just” the interface. Since Microsoft is pushing PowerShell, I believe official successor wmic would be PowerShell commandlet Get-WmiObject. How to use this can be found on Microsoft documentation: LINK [UPDATED] As … Read more

Python CLI program unit testing

Start from the user interface with functional tests and work down towards unit tests. It can feel difficult, especially when you use the argparse module or the click package, which take control of the application entry point. The cli-test-helpers Python package has examples and helper functions (context managers) for a holistic approach on writing tests … Read more