I have a Python program and I want to run it using command:
myprogram --readpower=some argument
Code
import click
import csv
import json
import sys
@click.group(invoke_without_command=True)
@click.option('--version', is_flag=True, default=False, help='Prints out pyisg package version being used')
def cli(version):
"""
This utility is used to convert a CSV file to JSON file
"""
if version:
print("This is version 1.0 software")
sys.exit()
@cli.command()
@click.option('--readpower', type=str, default="",
help='Path of the csv file which is to be read)')
def read_csv(readpower,readspike,readdip):
{
if readpower:
print("reading power")
}
if __name__ == "__main__":
cli()
The problem I am facing is that the command -
myprogram --readpower = some argument
does not work. I have to write the command as :
myprogram read_csv --readpower = some argument