-1

I am new to using click package if I give one to two commands and run it its not giving output, please look at my code and suggest what I can do.

import click
@click.group()
@click.option('--removedigits',default=False,help='remove digits from input')
@click.argument('name')
def cli(removedigits,name):
      '''supports some string commands from command line'''
      if(removedigits):
           output=[]
           for ch in name:
               if not ch.isdigit():
                   output.append(ch)
           print(''.join(output))

@cli.command()
def concat():
'''concatnates passed in strings with delimiter'''
   pass

if I enter the command as --removedigits concat -d, one1 two2 it should produce output as one, two

Can anyone explain how should I proceed?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
as_1234
  • 11

1 Answers1

0

edit:

if the problem is how to call your script, it tells you how in the --help screen: "[OPTIONS] NAME COMMAND [ARGS]"

but '--removedigits' is not a flag (indicated by is_flag) so click expects an argument after it, so you should add it to the option that its a flag:

@click.option('--removedigits',default=False,help='remove digits from input', is_flag=True)

AntiMatterDynamite
  • 1,495
  • 7
  • 17
  • i wanted to use with click only ,i didnt include if__name__=='main' here .just i wrote overview of code. – as_1234 May 06 '18 at 08:40
  • can u say where i made wrong how should i pass input to concat func if i give command as --removedigits concat command – as_1234 May 06 '18 at 08:41