File tree 2 files changed +51
-2
lines changed
2 files changed +51
-2
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python3
2
+ """
3
+ Author : NowHappy <[email protected] >
4
+ Date : 2021-10-02
5
+ Purpose: Rock the Casbah
6
+ """
7
+
8
+ import argparse
9
+ import os
10
+
11
+
12
+ # --------------------------------------------------
13
+ def get_args ():
14
+ """Get command-line arguments"""
15
+
16
+ parser = argparse .ArgumentParser (
17
+ description = 'howler (upper-cases input)' ,
18
+ formatter_class = argparse .ArgumentDefaultsHelpFormatter )
19
+
20
+ parser .add_argument ('input' ,
21
+ metavar = 'text' ,
22
+ help = 'Input string or file' )
23
+
24
+ parser .add_argument ('-o' ,
25
+ '--outfile' ,
26
+ help = 'Output filename' ,
27
+ metavar = 'str' ,
28
+ type = argparse .FileType ('wt' ),
29
+ default = '' )
30
+
31
+ return parser .parse_args ()
32
+
33
+
34
+ # --------------------------------------------------
35
+ def main ():
36
+ """Make a jazz noise here"""
37
+
38
+ args = get_args ()
39
+ str_args = args .input
40
+ outfile_args = args .outfile
41
+
42
+ if os .path .isfile (args .input ):
43
+ str_args = open (str_args ).read ()
44
+
45
+ print (f'{ str_args .upper ()} ' , file = outfile_args ) if outfile_args else print (f'{ str_args .upper ()} ' )
46
+
47
+
48
+ # --------------------------------------------------
49
+ if __name__ == '__main__' :
50
+ main ()
Original file line number Diff line number Diff line change 1
- this is some text
2
- this is some more text
1
+ test222
You can’t perform that action at this time.
0 commit comments