bash
pip install click
python
import click
@click.command()
@click.option('--operation', '-o', type=click.Choice(['add', 'subtract', 'multiply', 'divide']), help='Operation to perform.')
@click.argument('operand1', type=click.INT)
@click.argument('operand2', type=click.INT)
def calculator(operation, operand1, operand2):
"""Simple calculator tool."""
if operation == 'add':
result = operand1 + operand2
elif operation == 'subtract':
result = operand1 - operand2
elif operation == 'multiply':
result = operand1 * operand2
else:
result = operand1 / operand2
click.echo(f'Result: {result}')
if __name__ == '__main__':
calculator()
bash
python calculator.py --operation add 10 20