#!/usr/local/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 . ## ############################################################################## DEBUG = false # enable for verbose messages function check_dir(directory) if ispath(directory) if DEBUG == true print("The directory: ", directory, " already exists\n") end return true else if DEBUG == true print("The directory: ", directory, " does not exist\n") end return false 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) subDirs = ["src", "lib"] for dirs in subDirs mkpath("$projectDir/$dirs") end projectName = rsearchindex(projectDir, "/" ) if DEBUG == true print(projectName, "\n") end projectName = projectDir[projectName+1:length(projectDir)] touch("$projectDir/src/$projectName.jl") touch("$projectDir/README.md") touch("$projectDir/LICENSE") git_init("$projectDir") 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() print("\n", "useage: jprog init ", "\n", "\n") print("init Create a new project\n") end function main() if (length(ARGS) == 2 && ARGS[1] == "init") if DEBUG == true print("ARGS Count: ", length(ARGS), "\n") end if check_dir(ARGS[2]) == true if DEBUG == true print("Dir exists") end else create_default_structure(ARGS[2]) if check_dir(ARGS[2]) == true print("Project: ", ARGS[2], " created\n") else print("The directory: ", ARGS[2], " could not be created\n") end end else help() end end main()