code cleanup

This commit is contained in:
mollusk 2018-11-07 04:59:10 -07:00
parent 1f241d8c44
commit 653780457d

View File

@ -49,7 +49,7 @@ end
function create_default_structure(projectDir) function create_default_structure(projectDir)
subDirs = ["src", "lib"] local subDirs = ["src", "lib"]
for dirs in subDirs for dirs in subDirs
mkpath("$projectDir/$dirs") mkpath("$projectDir/$dirs")
@ -65,14 +65,15 @@ function create_default_structure(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) function git_init(projectPath)
LibGit2.init("$projectPath", false) # Initialize git repository LibGit2.init("$projectPath", false) # Initialize git repository
if check_dir("$projectPath/.git") == true if check_dir("$projectPath/.git") != true
print("Initialized git repository in $projectPath\n") print("Failed to initialize git repository in: ", pwd(), "/$projectPath\n")
else
print("Git repository initialized\n")
end end
end end
@ -88,20 +89,22 @@ function version()
end end
function main() function main()
local projectName = ARGS[2]
if (length(ARGS) == 2 && ARGS[1] == "init") if (length(ARGS) == 2 && ARGS[1] == "init")
if DEBUG == true print("ARGS Count: ", length(ARGS), "\n") end if DEBUG == true print("ARGS Count: ", length(ARGS), "\n") end
if check_dir(ARGS[2]) == true if check_dir(projectName) == true
if DEBUG == true print("Dir exists") end if DEBUG == true print("Dir exists") end
else else
create_default_structure(ARGS[2]) create_default_structure(projectName)
if check_dir(ARGS[2]) == true if check_dir(projectName) == true
print("Project: ", ARGS[2], " created\n") print("Project: '", projectName, "' was successfully created in: ", pwd(), "/$projectName\n")
git_init("$projectName")
else else
print("The directory: ", ARGS[2], " could not be created\n") print("The directory: '", projectName, "' could not be created\n")
end end
end end