Create CLI for python

Using google fire lib to create a CLI in python
linux
ubuntu
Published

December 15, 2020

Create CLI for python using Fire

Fire is a really simple library to build CLI. Install it ( you can use conda as well):

pip install fire

And then use it in your app, for example here:

import pandas as pd
import fire

def to_csv(fileName,sheet,outfile):
 df = pd.read_excel(fileName,sheet=sheet)
 for c in df.columns:
  df[c]= df[c].astype(str)
  df[c] = df[c].str.replace(r"/\n\r|\n|\r/g",'')
  df[c] = df[c].str.strip()
 df.to_csv(outfile,index=False,header=False)
 

if __name__ == '__main__':
  fire.Fire(to_csv)