From 7ebf0298b1bcd9bfecf58e5cb45fd3ec642bf138 Mon Sep 17 00:00:00 2001 From: Sangelo Date: Mon, 6 Mar 2023 17:27:29 +0100 Subject: [PATCH] more git init repo setup --- niminit.nim | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/niminit.nim b/niminit.nim index 8829e20..45faecb 100644 --- a/niminit.nim +++ b/niminit.nim @@ -1,5 +1,6 @@ import os import strutils +import strformat var count = 0 for entry in walkDir("."): @@ -54,7 +55,28 @@ else: if "-g" in (commandLineParams()): let createdRepo = execShellCmd("git init") if createdRepo == 0: - echo "Successfully created local git repository!" + echo "Successfully initialised local git repository!" + echo "Would you like to configure it? [Y/n]" + var input = stdin.readLine() + case input.toLower + of "yes", "y", "z", "j", "": + echo "Enter the git remote:" + let gitRemote = stdin.readLine() + echo "Enter your desired branch name:" + let gitBranch = stdin.readLine() + echo "Setting values..." + let setupGitRepo = execShellCmd(&"git remote add origin {gitRemote}") + let setGitBranch = execShellCmd(&"git branch -m {gitBranch}") + if setupGitRepo == 0: + echo &"Successfully added remote {gitRemote}" + else: + echo &"Failed to add remote {gitRemote}" + if setGitBranch == 0: + echo &"Successfully set branch to {gitBranch}" + else: + echo &"Failed to set branch {gitBranch}" + else: + echo "Successfully created local git repository!" else: echo: "Failed creating local git repository."