cat hello.txt | python main.py foobar
what is the reason of using cat
here?
I understand foobar
is command line argument so I need to handle it with arguments parser. how to handle it if i do not specify parameter e.g. --parameters
?
what about hello.txt
used after cat
?
is it the name of the file that i am passing into python main.py
call as other argument or am I dumping python main.py
execution results into hello.txt
? how and what exactly? am I catching what python main.py
is printing with cat
and writing it into hello.txt
?
EDIT:
Am i capturing it correct?
import argparse
import sys
def parse_arguments():
parser = argparse.ArgumentParser()
parser.add_argument('a', nargs='*')
args, unknown = parser.parse_known_args()
return args
file_content = data = sys.stdin.read()
params = parse_arguments()
print(file_content)
print(params)