Skip to content

Commit

Permalink
kyclark#5 joy.y
Browse files Browse the repository at this point in the history
  • Loading branch information
joy committed Oct 2, 2021
1 parent c14bd30 commit 050bca1
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
50 changes: 50 additions & 0 deletions 05_howler/howler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env python3
"""
Author : NowHappy <[email protected]>
Date : 2021-10-02
Purpose: Rock the Casbah
"""

import argparse
import os


# --------------------------------------------------
def get_args():
"""Get command-line arguments"""

parser = argparse.ArgumentParser(
description='howler (upper-cases input)',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)

parser.add_argument('input',
metavar='text',
help='Input string or file')

parser.add_argument('-o',
'--outfile',
help='Output filename',
metavar='str',
type=argparse.FileType('wt'),
default='')

return parser.parse_args()


# --------------------------------------------------
def main():
"""Make a jazz noise here"""

args = get_args()
str_args = args.input
outfile_args = args.outfile

if os.path.isfile(args.input):
str_args = open(str_args).read()

print(f'{str_args.upper()}', file=outfile_args) if outfile_args else print(f'{str_args.upper()}')


# --------------------------------------------------
if __name__ == '__main__':
main()
3 changes: 1 addition & 2 deletions inputs/out.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
this is some text
this is some more text
test222

0 comments on commit 050bca1

Please sign in to comment.