mxloc - counts the lines of your project

Monkey Archive Forums/Monkey Discussion/mxloc - counts the lines of your project

Shinkiro1(Posted 2017) [#1]
This was more a curiosity thing, than actually being useful.
And because cloc doesn't work for monkey, I wrote a simple line counter myself (in monkey of course):

Github: https://github.com/frameland/mxloc
(build it with the cpp target)

Enjoy.


Simonsuuri(Posted 2017) [#2]
this is cool but i cant find a way to use it :/ Error is "Specify project as argument"
builded it with cpp tool and tried it trough cmd
where i should put the argument ?


Shinkiro1(Posted 2017) [#3]
It's a command line tool, so you write the path to mxloc, then the path to your project as an argument.
E.g like this:
./mxloc ~/dev/projects/mygame

Edit: mxloc should be in your build dir after you built it.


Simonsuuri(Posted 2017) [#4]
yay i got it working
path to mxloc.exe and then: mxloc "path to project folder to count for"

Thanks


Simonsuuri(Posted 2017) [#5]
i made a bat file called countLines.bat wich looks for linecount from bat file location
code for bat file:

cd c:\monkey games\CountLines
mxloc "%~dp0"
PAUSE

%~dp0 gives bat file location

i needed to chance mcloc.monkey litllebit
Function ProjectPathFromArg:String()
	Local args:= os.AppArgs()
	If args.Length <> 2
		Return ""
	End
	Return args[1][ .. args[1].Length() -1]      'CHANGED Removes last letter from given path (with out this )
End


now it feels more handy for me :3


Simonsuuri(Posted 2017) [#6]
And Now i actually edited mxloc.monkey more

now the .exe file search monkey files from .exe file location

i Removed ProjectPathFromArg() function
	Local path:String = os.CurrentDir()                        ' replaced ProjectPathFromArg() With os.CurrentDir()
		If Not path
			Print "Specify the project folder as argument."
			Print "Exiting ..."
			Return 1
		Else
			Print "Project Path: " + path                 'Added print path
		End


and added line at end of Main() function

		os.Execute("PAUSE")                                   'wait anykey


to use you only need to move mxloc.exe file to project folder what to count and execute it

Edit: I also made standalone.exe (Glfw3)
i had to make font that doest need font image to do it but its done now, it uses array data to draw letters :D i shall share it when i find good way to share it :)


Shinkiro1(Posted 2017) [#7]
Hey that's cool, nice that you are extending it.

I wanted to make it as small as possible, that's why i used the stdcpp target (and no dependencies).
Also, I don't know if "PAUSE" is cross platform (at least it's not a command in OSX)

For the path you could also do it like this:
Local path:String = ProjectPathFromArg()
If Not path
	path = is.CurrentDir()
End

Then you can still call it with arguments, but it will take the current dir if it's not provided.