Added debug mode, git support, license

This commit is contained in:
mollusk 2017-09-04 00:13:05 -07:00
parent cda17bd6ef
commit d8453b02f6

View File

@ -1,20 +1,51 @@
#!/usr/bin/julia #!/usr/bin/julia
###############################################################################
##
##
## Copyright (C) 2017 Justin Moore
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
##
##############################################################################
DEBUG = false # enable for verbose messages
function check_dir(directory) function check_dir(directory)
if ispath(directory) if ispath(directory)
print("The directory: ", directory, " :already exists\n") if DEBUG == true print("The directory: ", directory, " already exists\n") end
return true return true
else else
print("The directory: ", directory, " :does not exist\n") if DEBUG == true print("The directory: ", directory, " does not exist\n") end
return false return false
end end
end end
function check_file(filePath)
if isfile(filePath)
if DEBUG == true print("File: ", filePath, " exists\n") end
return true
else
if DEBUG == false print("File: ", filePath, " does not exist\n") end
return false
end
end
function create_default_structure(projectDir) function create_default_structure(projectDir)
subDirs = ["src", "lib"] subDirs = ["src", "lib"]
@ -26,34 +57,43 @@ function create_default_structure(projectDir)
projectName = rsearchindex(projectDir, "/" ) projectName = rsearchindex(projectDir, "/" )
print(projectName, "\n") if DEBUG == true print(projectName, "\n") end
projectName = projectDir[projectName+1:length(projectDir)] projectName = projectDir[projectName+1:length(projectDir)]
touch("$projectDir/src/$projectName.jl") touch("$projectDir/src/$projectName.jl")
touch("$projectDir/README.md") touch("$projectDir/README.md")
touch("$projectDir/LICENSE") touch("$projectDir/LICENSE")
git_init("$projectDir")
end end
function git_init(projectPath)
LibGit2.init("$projectPath", false) # Initialize git repository
if check_dir("$projectPath/.git") == true
print("Initialized git repository in $projectPath\n")
end
end
function help() function help()
print("This will be help\n") print("\n", "useage: jprog init <project name>", "\n", "\n")
print("init Create a new project\n")
end end
function main() function main()
if (length(ARGS) == 2 && ARGS[1] == "init") if (length(ARGS) == 2 && ARGS[1] == "init")
print(length(ARGS), "\n") if DEBUG == true print("ARGS Count: ", length(ARGS), "\n") end
if check_dir(ARGS[2]) == true if check_dir(ARGS[2]) == true
print("Dir exists") if DEBUG == true print("Dir exists") end
else else
create_default_structure(ARGS[2]) create_default_structure(ARGS[2])
if check_dir(ARGS[2]) == true if check_dir(ARGS[2]) == true
print("Directory: ", ARGS[2], " created\n") print("Project: ", ARGS[2], " created\n")
else else
print("The directory: ", ARGS[2], " could not be created\n") print("The directory: ", ARGS[2], " could not be created\n")
end end