command-line-interface

How to install private python package from Azure Artifact feed via CLI

How to install private python package from Azure Artifact feed via CLI Question: I have setup a pypi feed in Azure Artifacts, but I can’t seem to be able to authenticate via CLI to be able to install the python packages locally. I want to be able to just run pip install and provide the …

Total answers: 2

S3 Default server side encryption on large number of buckets using Python boto3

S3 Default server side encryption on large number of buckets using Python boto3 Question: Hi Iam trying to turn on default s3 encryption on all my buckets in an account using python boto3 script see below. import boto3 from botocore.exceptions import ClientError s3 = boto3.client(‘s3’) response = s3.list_buckets() for bucket in response[‘Buckets’]: enc = s3.get_bucket_encryption(Bucket=bucket[‘Name’]) …

Total answers: 2

Automatically generate all help documentation for Click commands

Automatically generate all help documentation for Click commands Question: Is there a way to generate (and export) help documentation using click for all commands and subcommands? For example, cli –help all –destination help-docs.txt would generate help for commands and subcommands following the cli command subcommand format and put them into the help-docs.txt file. The only …

Total answers: 2

Divide click commands into sections in cli documentation

Divide click commands into sections in cli documentation Question: This code: #!/usr/bin env python3 import click def f(*a, **kw): print(a, kw) commands = [click.Command(“cmd1”, callback=f), click.Command(“cmd2”, callback=f)] cli = click.Group(commands={c.name: c for c in commands}) if __name__ == “__main__”: cli() generates this help: # Usage: cli.py [OPTIONS] COMMAND [ARGS]… # Options: # –help Show this …

Total answers: 2

How to create a CLI in Python that can be installed with PIP?

How to create a CLI in Python that can be installed with PIP? Question: As the title suggests, I’m trying to make a python script accessible from the command line. I’ve found libraries like click and argv that make it easy to access arguments passed from the command line, but the user still has to …

Total answers: 4

AWS cli windows – still getting "'aws' is not recognized…" after adding path to environment variables?

AWS cli windows – still getting "'aws' is not recognized…" after adding path to environment variables? Question: Following instructions found here (and elsewhere) I added ‘%USERPROFILE%AppDataRoamingPythonPython37Scriptsaws’ to Path (tried with and without aws at the end) I clicked OK everywhere and restartet the CLI, but I am still getting “‘aws’ is not recognized as an …

Total answers: 2

python click set allowable values for option

python click set allowable values for option Question: I have created a Click command that will copy files from source to destination The command accepts 3 parameters : 1 – Source of files 2 – Destination of files 3 – Transfer mode (local,ftp) import click @click.group() def cli(): pass @cli.command() @click.argument(‘source’) @click.argument(‘destination’) @click.option(‘–mode’, required = …

Total answers: 1

Require an option only if a choice is made when using click

Require an option only if a choice is made when using click Question: When using click I know how to define a multiple choice option. I also know how to set an option as a required one. But, how can I indicate that an option B is required only if the value of option A …

Total answers: 3

Python Click – Supply arguments and options from a configuration file

Python Click – Supply arguments and options from a configuration file Question: Given the following program: #!/usr/bin/env python import click @click.command() @click.argument(“arg”) @click.option(“–opt”) @click.option(“–config_file”, type=click.Path()) def main(arg, opt, config_file): print(“arg: {}”.format(arg)) print(“opt: {}”.format(opt)) print(“config_file: {}”.format(config_file)) return if __name__ == “__main__”: main() I can run it with the arguments and options provided through command line. $ …

Total answers: 2

Create Python CLI with select interface

Create Python CLI with select interface Question: I’d like to create a Python CLI with an item selection interface that allows users to choose an item from a list. Something like: Select a fruit (up/down to select and enter to confirm): [x] Apple [ ] Banana [ ] Orange I’d like users to be able …

Total answers: 3