fs, configFile, treeDir change

This commit is contained in:
mane 2020-04-05 00:54:21 +04:00
parent a36f236bb3
commit 0e89e907fd
2 changed files with 78 additions and 40 deletions

View file

@ -1,42 +1,43 @@
MODULE Vipack; MODULE Vipack;
IMPORT vpkConf, vpkFsHelper, vpkLogger, vpkPackageFileParser, Texts, Strings, In, Platform, Oberon, Out, Files, vpkUserDetails; IMPORT vpkConf, vpkLogger, vpkPackageFileParser, Texts, Strings, In, Platform, Oberon, Out, Files, vpkUserDetails;
PROCEDURE main(); PROCEDURE main();
CONST confFileName = "/vipack.conf"; CONST confFileName = "vipack.conf";
CONST syncDirName = "tree/";
VAR user, str, fn: ARRAY 32 OF CHAR; VAR user, str: ARRAY 32 OF CHAR;
confPath, string : ARRAY 120 OF CHAR; confPath, curPath, string : 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;
command : ARRAY 500 OF CHAR; defaultUrl,project,command : ARRAY 500 OF CHAR;
PROCEDURE help(); PROCEDURE help();
BEGIN BEGIN
vpkLogger.Log("HelpText"); vpkLogger.Log("HelpText");
END help; END help;
BEGIN BEGIN
(* Getting 1 argument and outputting it *) (* Getting 1 argument and outputting it *)
Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); 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";
(* Vipack installation or help *)
command := S.s; command := S.s;
confPath := "/home//.vipack/";
(*HELP*)
IF Strings.Match(command, "") OR Strings.Match(command, "--help")THEN IF Strings.Match(command, "") OR Strings.Match(command, "--help")THEN
help; help;
ELSIF Strings.Match(command, "install") THEN
vpkPackageFileParser.install();
END; END;
confPath := "/home//.vipack";
(* Getting username from input if there is no $USER variable *) (* Getting username from input if there is no $USER variable *)
IF ~(vpkUserDetails.GetUsername(user)) THEN IF ~(vpkUserDetails.GetUsername(user)) THEN
Out.String("username: "); In.Line(user); Out.String("username: "); In.Line(user);
@ -45,22 +46,56 @@ END;
(* Making the full path to vipack.conf *) (* Making the full path to vipack.conf *)
Strings.Insert(user,6,confPath); Strings.Insert(user,6,confPath);
Out.String(confPath);Out.Ln; Out.String(confPath);Out.Ln;
curPath := confPath;
(* Checking if ~/.vipack directory already exists *) (* Checking if ~/.vipack directory already exists *)
IF ~(vpkFsHelper.mkDir(confPath)) THEN IF vpkConf.makeDir(confPath) THEN
Out.String(confPath); Out.String(" already exists or path is wrong");Out.Ln; Out.String("Creating directory "); Out.String(confPath);Out.Ln;
ELSE Out.String("Creating directory "); Out.String(confPath);Out.Ln; ELSE Out.String(confPath); 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,confPath); Strings.Append(confFileName,curPath);
IF ~(vpkConf.confExists(confPath)) THEN IF ~(vpkConf.confExists(curPath)) 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(confPath); vpkConf.makeConf(curPath,f);
Files.Set(r, f, 0);
Files.WriteInt(r, 8); Files.WriteString(r, " PATH :"); Files.WriteString(r,defaultUrl);
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 *)
curPath := confPath;
(*ELSIF Strings.Match(command, "install") THEN
vpkPackageFileParser.install();
END;*)
IF command = "sync" THEN
Strings.Append(syncDirName, curPath);
(*Check tree directory if doesn't exist create*)
IF vpkConf.makeDir(curPath) THEN
Out.String("Creating "); Out.String(curPath); Out.String("for syncing");Out.Ln;
ELSE Out.String("Some error occured or directory already exist");
END;
(*Sync*)
(*git.sync();*)
END;
IF command = "install" THEN
Texts.Scan(S);
project := S.s;
Out.String(project);Out.Ln;
END;
Out.String(user); Out.Ln; Out.String(user); Out.Ln;
END main; END main;

View file

@ -15,45 +15,48 @@ copy-version-file-to-build-dir:
all: http all: http
cd builds && \ cd builds && \
$(VOC) -s \ $(VOC) -s \
../Settings.Mod \ ../vpkFsHelper.Mod \
../time.Mod \ ../vpkConf.Mod \
../logger.Mod \ ../vpkUserDetails.Mod \
../vpkSettings.Mod \
../vpkTime.Mod \
../vpkLogger.Mod \
../diaspora2hugo/src/lists/Sys.Mod \ ../diaspora2hugo/src/lists/Sys.Mod \
../diaspora2hugo/src/lists/List.Mod \ ../diaspora2hugo/src/lists/List.Mod \
../diaspora2hugo/src/lists/strutils.Mod \ ../diaspora2hugo/src/lists/strutils.Mod \
../CharacterStack.Mod \ ../vpkCharacterStack.Mod \
../JsonParser.Mod \ ../vpkJsonParser.Mod \
../FileManager.Mod \ ../vpkFileManager.Mod \
../PackageResolver.Mod \ ../vpkPackageResolver.Mod \
../DependencyResolver.Mod \ ../vpkDependencyResolver.Mod \
../PackageFileParser.Mod \ ../vpkPackageFileParser.Mod \
../opium.Mod -m ../Vipack.Mod -m
run: run:
./builds/opium install ./builds/Vipack install
http: clean http: clean
cd builds && \ cd builds && \
$(VOC) -s ../time.Mod \ $(VOC) -s ../vpkTime.Mod \
../logger.Mod \ ../vpkLogger.Mod \
../types.Mod \ ../vpkTypes.Mod \
../sockets.Mod \ ../vpkSockets.Mod \
../netdb.Mod \ ../vpkNetdb.Mod \
../Internet.Mod \ ../vpkInternet.Mod \
../http.Mod ../vpkHttp.Mod
json: json:
cd builds && \ cd builds && \
$(VOC) -s \ $(VOC) -s \
../time.Mod \ ../vpkTime.Mod \
../logger.Mod \ ../vpkLogger.Mod \
../diaspora2hugo/src/lists/Sys.Mod \ ../diaspora2hugo/src/lists/Sys.Mod \
../diaspora2hugo/src/lists/List.Mod \ ../diaspora2hugo/src/lists/List.Mod \
../diaspora2hugo/src/lists/strutils.Mod \ ../diaspora2hugo/src/lists/strutils.Mod \
../CharacterStack.Mod \ ../vpkCharacterStack.Mod \
../JsonParser.Mod ../vpkJsonParser.Mod
clean: clean:
rm -r builds & rm -r builds &