Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added windows & unix style command line arguments #1

Merged
merged 5 commits into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ The location to a source file must be supplied.
#### From the command line
```
python gus.py example.html
python gus.py -f example.html or python gus.py --file example.html to check a file
python gus.py -v or python gus.py --version for version info
python gus.py -h or python gus.py --help for help
```
#### From the python shell
```
Expand Down
17 changes: 13 additions & 4 deletions gus.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,19 @@ def get_help():
help = open('help.txt').read()
print(help)
except:
print("error printing help")
print("error printing help")

if __name__ == "__main__":
if (len(sys.argv)==1):
get_help() # calls for help if no arg provided
if len(sys.argv) == 1:
get_help() # calls for help if no arg provided
elif len(sys.argv) == 2 and str(sys.argv[1])[:1] != "-":
tavo(str(sys.argv[1])) # send command line arg to main function
else:
tavo(str(sys.argv[1])) # send command line arg to main function
if len(sys.argv) == 3 and (sys.argv[1] == "-f" or sys.argv[1] == "--file"):
tavo(str(sys.argv[2])) # send command line arg to main function
elif len(sys.argv) == 2 and (sys.argv[1] == "-v" or sys.argv[1] == "--version"):
print('Get-Url-Status (GUS) Text-As-Visual-Output (TAVO) version 0.1') # print version info
elif len(sys.argv) == 2 and (sys.argv[1] == "-h" or sys.argv[1] == "--help"):
get_help()
else:
print('invalid argument error') # print if user inputs wrong argument or if there are too many arguments
15 changes: 13 additions & 2 deletions help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,23 @@
GUS can be used from the command line or python shell
The location to a source file must be supplied.

From the command line:
To check files from the command line:
>>> python gus.py example.txt
or
>>> python gus.py ~/another/file.html
or
>>> python gus.py -f or --file example.txt
or
>>> python gus.py -f or --file ~/another/file.html

To check version information:
>>> python gus.py -v or --version

To get help:
>>> python gus.py -h or --help


From the python shell:
To check files from the python shell:
>>> import gus
>>> gus.tavo("your.filename.here")

Expand Down