diff --git a/src/jprog.jl b/src/jprog.jl
index 8811be8..4873f33 100755
--- a/src/jprog.jl
+++ b/src/jprog.jl
@@ -19,9 +19,12 @@
## along with this program. If not, see .
##
##############################################################################
+
import LibGit2
+
DEBUG = false # enable for verbose messages
+# Generic directory checking with boolean returns
function check_dir(directory)
if ispath(directory)
@@ -36,8 +39,11 @@ function check_dir(directory)
end
+# Generic file checking with boolean returns
function check_file(filePath)
+
if isfile(filePath)
+
if DEBUG == true print("File: ", filePath, " exists\n") end
return true
@@ -47,18 +53,22 @@ function check_file(filePath)
end
end
+# Somewhat automate creating directories
function create_default_structure(projectDir)
local subDirs = ["src", "lib"]
for dirs in subDirs
mkpath("$projectDir/$dirs")
+
end
-
+ # check whether projectDir contains /
projectName = occursin(projectDir, "/" )
if DEBUG == true print(projectName, "\n") end
+
+ # append name of project to main source file name
projectName = projectDir[projectName+1:length(projectDir)]
@@ -67,9 +77,13 @@ function create_default_structure(projectDir)
touch("$projectDir/LICENSE")
end
+# Establish a Git repository in project root
function git_init(projectPath)
- LibGit2.init("$projectPath", false) # Initialize git repository
+
+ LibGit2.init("$projectPath", false)
+
if check_dir("$projectPath/.git") != true
+
print("Failed to initialize git repository in: ", pwd(), "/$projectPath\n")
else
@@ -77,17 +91,20 @@ function git_init(projectPath)
end
end
+# Print a list of supported commands
function help()
print("\n", "useage: jprog init ", "\n", "\n")
print("init Create a new project\n")
end
+# Get version information for this program
function version()
print("\n", "Version 1\n\n")
end
+# Take arguments from the shell and process them
function main()
local projectName = ARGS[2]
@@ -96,12 +113,16 @@ function main()
if DEBUG == true print("ARGS Count: ", length(ARGS), "\n") end
if check_dir(projectName) == true
+
if DEBUG == true print("Dir exists") end
else
create_default_structure(projectName)
+
if check_dir(projectName) == true
+
print("Project: '", projectName, "' was successfully created in: ", pwd(), "/$projectName\n")
+
git_init("$projectName")
else
print("The directory: '", projectName, "' could not be created\n")