Creating an command line application in a markdown file.¶
import click
We’ll use the click library as our package for making a "CLI"
@click.command()
@click.argument('word')
def main(word):
main is a function that take ones argument.
It is capitalized and printed in the terminal
click.echo(F"{__file__} is a program that can only print in uppercase:".upper())
click.echo(word.upper())
if __name__ == '__main__':
if '__file__' in locals():
We are using the command line interface because python added a __file__ attribute to the module.
main()
else:
We are running in an interactive notebook context.