mirror of
https://github.com/vishapoberon/vipak.git
synced 2026-04-06 13:02:26 +00:00
vpkGit.Mod(clone), confPath change (v1)
This commit is contained in:
parent
0e89e907fd
commit
d75b48915d
3 changed files with 51 additions and 28 deletions
60
Vipack.Mod
60
Vipack.Mod
|
|
@ -1,5 +1,5 @@
|
||||||
MODULE Vipack;
|
MODULE Vipack;
|
||||||
IMPORT vpkConf, vpkLogger, vpkPackageFileParser, Texts, Strings, In, Platform, Oberon, Out, Files, vpkUserDetails;
|
IMPORT vpkGit, vpkConf, vpkLogger, vpkPackageFileParser, Texts, Strings, In, Platform, Oberon, Out, Files, vpkUserDetails;
|
||||||
|
|
||||||
PROCEDURE main();
|
PROCEDURE main();
|
||||||
|
|
||||||
|
|
@ -7,13 +7,13 @@ CONST confFileName = "vipack.conf";
|
||||||
CONST syncDirName = "tree/";
|
CONST syncDirName = "tree/";
|
||||||
|
|
||||||
VAR user, str: ARRAY 32 OF CHAR;
|
VAR user, str: ARRAY 32 OF CHAR;
|
||||||
confPath, curPath, string : ARRAY 120 OF CHAR;
|
vpkDirPath, treePath, confPath : ARRAY 120 OF CHAR;
|
||||||
i : INTEGER;
|
i : INTEGER;
|
||||||
f : Files.File;
|
f : Files.File;
|
||||||
r : Files.Rider;
|
r : Files.Rider;
|
||||||
ch : CHAR;
|
ch : CHAR;
|
||||||
S: Texts.Scanner;
|
S: Texts.Scanner;
|
||||||
defaultUrl,project,command : ARRAY 500 OF CHAR;
|
defaultUrl,gitUrl,project,command,string : ARRAY 500 OF CHAR;
|
||||||
|
|
||||||
PROCEDURE help();
|
PROCEDURE help();
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
@ -27,47 +27,42 @@ Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos);
|
||||||
Texts.Scan(S);
|
Texts.Scan(S);
|
||||||
Out.String(S.s); Out.Ln;
|
Out.String(S.s); Out.Ln;
|
||||||
|
|
||||||
defaultUrl := "https://github.com/PizzaPablo666/test";
|
defaultUrl := "https://github.com/norayr/diaspora";
|
||||||
|
|
||||||
command := S.s;
|
command := S.s;
|
||||||
|
|
||||||
confPath := "/home//.vipack/";
|
IF ~(Platform.getEnv("HOME", vpkDirPath)) THEN
|
||||||
|
Out.String("HOME variable is not found"); Out.Ln;
|
||||||
|
END;
|
||||||
|
|
||||||
(*HELP*)
|
(*HELP*)
|
||||||
IF Strings.Match(command, "") OR Strings.Match(command, "--help")THEN
|
IF Strings.Match(command, "") OR Strings.Match(command, "--help")THEN
|
||||||
help;
|
help;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
(* Getting username from input if there is no $USER variable *)
|
Strings.Append("/.vipack/",vpkDirPath);
|
||||||
IF ~(vpkUserDetails.GetUsername(user)) THEN
|
confPath := vpkDirPath;
|
||||||
Out.String("username: "); In.Line(user);
|
treePath := vpkDirPath;
|
||||||
END;
|
|
||||||
|
|
||||||
(* Making the full path to vipack.conf *)
|
|
||||||
Strings.Insert(user,6,confPath);
|
|
||||||
Out.String(confPath);Out.Ln;
|
|
||||||
curPath := confPath;
|
|
||||||
|
|
||||||
(* Checking if ~/.vipack directory already exists *)
|
(* Checking if ~/.vipack directory already exists *)
|
||||||
IF vpkConf.makeDir(confPath) THEN
|
IF vpkConf.makeDir(vpkDirPath) THEN
|
||||||
Out.String("Creating directory "); Out.String(confPath);Out.Ln;
|
Out.String("Creating directory "); Out.String(vpkDirPath);Out.Ln;
|
||||||
ELSE Out.String(confPath); Out.String(" already exists or path is wrong");Out.Ln;
|
ELSE Out.String(vpkDirPath); Out.String(" already exists or path is wrong");Out.Ln;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
(* Checking if vipack.conf already exists *)
|
(* Checking if vipack.conf already exists *)
|
||||||
Strings.Append(confFileName,curPath);
|
Strings.Append(confFileName,confPath);
|
||||||
|
|
||||||
IF ~(vpkConf.confExists(curPath)) THEN
|
IF ~(vpkConf.confExists(confPath)) THEN
|
||||||
Out.String("Creating the configuration file "); Out.String(confPath);Out.Ln;
|
Out.String("Creating the configuration file "); Out.String(confPath);Out.Ln;
|
||||||
vpkConf.makeConf(curPath,f);
|
vpkConf.makeConf(confPath,f);
|
||||||
Files.Set(r, f, 0);
|
Files.Set(r, f, 0);
|
||||||
Files.WriteInt(r, 8); Files.WriteString(r, " PATH :"); Files.WriteString(r,defaultUrl);
|
(*Files.WriteInt(r, 8)*); Files.WriteString(r, " PATH :"); Files.WriteString(r,defaultUrl);
|
||||||
Files.Close(f);
|
Files.Close(f);
|
||||||
ELSE
|
ELSE
|
||||||
Out.String("File already exists");Out.Ln;
|
Out.String("File already exists");Out.Ln;
|
||||||
END;
|
END;
|
||||||
(*after adding file and working with it, then removing the file part in the path *)
|
(*after adding file and working with it, then removing the file part in the path *)
|
||||||
curPath := confPath;
|
|
||||||
|
|
||||||
|
|
||||||
(*ELSIF Strings.Match(command, "install") THEN
|
(*ELSIF Strings.Match(command, "install") THEN
|
||||||
|
|
@ -77,14 +72,25 @@ END;*)
|
||||||
|
|
||||||
|
|
||||||
IF command = "sync" THEN
|
IF command = "sync" THEN
|
||||||
Strings.Append(syncDirName, curPath);
|
Strings.Append(syncDirName, vpkDirPath);
|
||||||
(*Check tree directory if doesn't exist create*)
|
(*Check tree directory if doesn't exist create*)
|
||||||
IF vpkConf.makeDir(curPath) THEN
|
IF vpkConf.makeDir(treePath) THEN
|
||||||
Out.String("Creating "); Out.String(curPath); Out.String("for syncing");Out.Ln;
|
Out.String("Creating "); Out.String(treePath); Out.String("for syncing");Out.Ln;
|
||||||
ELSE Out.String("Some error occured or directory already exist");
|
ELSE Out.String("Some error occured or directory already exist");
|
||||||
END;
|
END;
|
||||||
(*Sync*)
|
(*Sync*)
|
||||||
(*git.sync();*)
|
f := Files.Old(confPath);
|
||||||
|
Files.Set(r,f,0);
|
||||||
|
Files.ReadLine(r,gitUrl);
|
||||||
|
Strings.Delete(gitUrl,0,6);
|
||||||
|
Out.String(gitUrl); Out.Ln;
|
||||||
|
string := gitUrl;
|
||||||
|
Strings.Delete(string,19,Strings.Length(string)-17);
|
||||||
|
Out.String(string);Out.Ln;
|
||||||
|
IF Strings.Match(string,"https://github.com/") OR Strings.Match(string,"git://github.com/") THEN
|
||||||
|
Out.String("YES"); Out.Ln;
|
||||||
|
vpkGit.clone(gitUrl);
|
||||||
|
END;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -96,8 +102,6 @@ IF command = "install" THEN
|
||||||
END;
|
END;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Out.String(user); Out.Ln;
|
|
||||||
END main;
|
END main;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
1
makefile
1
makefile
|
|
@ -15,6 +15,7 @@ copy-version-file-to-build-dir:
|
||||||
all: http
|
all: http
|
||||||
cd builds && \
|
cd builds && \
|
||||||
$(VOC) -s \
|
$(VOC) -s \
|
||||||
|
../vpkGit.Mod \
|
||||||
../vpkFsHelper.Mod \
|
../vpkFsHelper.Mod \
|
||||||
../vpkConf.Mod \
|
../vpkConf.Mod \
|
||||||
../vpkUserDetails.Mod \
|
../vpkUserDetails.Mod \
|
||||||
|
|
|
||||||
18
vpkGit.Mod
Normal file
18
vpkGit.Mod
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
MODULE vpkGit;
|
||||||
|
IMPORT Out,Strings, Platform;
|
||||||
|
|
||||||
|
PROCEDURE clone*(URL : ARRAY OF CHAR);
|
||||||
|
VAR i : INTEGER;
|
||||||
|
cmd : ARRAY 120 OF CHAR;
|
||||||
|
BEGIN
|
||||||
|
i:=Platform.System("git init .");
|
||||||
|
cmd := "git clone ";
|
||||||
|
Strings.Append(URL, cmd);
|
||||||
|
i := Platform.System(cmd);
|
||||||
|
Out.Int(i,0);
|
||||||
|
END clone;
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
|
||||||
|
END vpkGit.
|
||||||
Loading…
Add table
Add a link
Reference in a new issue