Skip to content

Commit

Permalink
separate command from logic, updated coverage badge refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
mark91m12 committed Apr 19, 2018
1 parent 86723bf commit c8a51cf
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MyWordCounter

[![Build Status](https://travis-ci.org/mark91m12/PitE-MyWordCounter.svg?branch=master)](https://travis-ci.org/mark91m12/PitE-MyWordCounter) [![Coverage Status](https://coveralls.io/repos/github/mark91m12/PitE-MyWordCounter/badge.svg)](https://coveralls.io/github/mark91m12/PitE-MyWordCounter) [![HitCount](http://hits.dwyl.io/mark91m12/PitE-MyWordCounter.svg)](http://hits.dwyl.io/mark91m12/PitE-MyWordCounter)
[![Build Status](https://travis-ci.org/mark91m12/PitE-MyWordCounter.svg?branch=master)](https://travis-ci.org/mark91m12/PitE-MyWordCounter) [![Coverage Status](https://coveralls.io/repos/github/mark91m12/PitE-MyWordCounter/badge.svg?branch=master&service=GitHub)](https://coveralls.io/github/mark91m12/PitE-MyWordCounter?branch=master&service=GitHub) [![HitCount](http://hits.dwyl.io/mark91m12/PitE-MyWordCounter.svg)](http://hits.dwyl.io/mark91m12/PitE-MyWordCounter)


**MyWordCounter** is an implementation of the Linux program WC ([Word Counter](https://en.wikipedia.org/wiki/Wc_(Unix)))
Expand Down
39 changes: 39 additions & 0 deletions myWC.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from Logic import MyWordCounter
import sys

myWordCounter = MyWordCounter()


def run_wc():
if len(sys.argv) == 1:
return (myWordCounter.all_counts(sys.stdin))
elif len(sys.argv) == 2:
if sys.argv[1][0] == "-":
if sys.argv[1] in myWordCounter.options:
return (myWordCounter.functions[sys.argv[1]](sys.stdin))
else:
return ("MyWordCounter: invalid option\nTry 'python Logic.py -h' for more information.")
else:
try:
txtFile = sys.argv[1]
txtFile = open(txtFile, 'r')
return (myWordCounter.all_counts(txtFile))
except IOError:
return ("MyWordCounter: ", txtFile, ": No such file or directory")

elif len(sys.argv) == 3:
if sys.argv[1] not in myWordCounter.options:
return ("MyWordCounter: invalid option\nTry 'python Logic.py -h' for more information.")
else:
try:
txtFile = sys.argv[2]
txtFile = open(txtFile, 'r')
return (myWordCounter.functions[sys.argv[1]](txtFile))
except IOError:
return ("MyWordCounter: ", txtFile, ": No such file or directory")
else:
return ("MyWordCounter: invalid input\nTry 'python Logic.py -h' for more information.")


if __name__ == '__main__':
print(run_wc())

0 comments on commit c8a51cf

Please sign in to comment.