-
-
Save CraigsOverItAll/58ac69a7b098ec04170eded9a62d01fc to your computer and use it in GitHub Desktop.
loc - Lines of Code (a simple bash script for a quick and dirty count of lines of code in an Xcode project, works with Swift, Objective-C, C and C++ files)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Quick and simple "Lines Of Code" script | |
# Colors for output | |
p="\033[38;5;208m" | |
g="\033[38;5;7m" | |
a="\033[38;5;10m" | |
# Colour end | |
e="\033[0;00m" | |
# Finally lets do some output | |
if [ $1 == "-s" ] | |
then | |
find . \( -iname \*.swift \) -exec wc -l '{}' \+ | |
elif [ $1 == "-o" ] | |
then | |
find . \( -iname \*.m -o -iname \*.mm -o -iname \*.h \) -exec wc -l '{}' \+ | |
elif [ $1 == "-m" ] | |
then | |
find . \( -iname \*.m -o -iname \*.mm -o -iname \*.h -o -iname \*.swift \) -exec wc -l '{}' \+ | |
elif [ $1 == "-a" ] | |
then | |
find . \( -iname \*.m -o -iname \*.mm -o -iname \*.c -o -iname \*.cc -o -iname \*.h -o -iname \*.hh -o -iname \*.hpp -o -iname \*.cpp -o -iname \*.swift \) -exec wc -l '{}' \+ | |
else | |
echo $g"Usage:"$e" loc "$a"[-s] [-o] [-m] [-a]"$e | |
echo "\tOutputs file line counts and a total for the project language specified." | |
echo "\t(File count will process the contents of the current directory" | |
echo "\tidealy, run this from the project or source root directory)" | |
echo | |
echo "Options:" | |
echo "\t-s\tReturns a file by file line count for a Swift project, with a total" | |
echo | |
echo "\t-o\tReturns a file by file line count for an Objective-C project, with a total" | |
echo | |
echo "\t-m\tReturns the line counts for a Mixed Swift and Objective-C project" | |
echo | |
echo "\t-a\tReturns the line count for Swift, Objective-C, C and C++ project" | |
echo | |
echo "\t--help\tor any unknown option shows this usage output." | |
echo | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment