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;
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();
CONST confFileName = "/vipack.conf";
CONST confFileName = "vipack.conf";
CONST syncDirName = "tree/";
VAR user, str, fn: ARRAY 32 OF CHAR;
confPath, string : ARRAY 120 OF CHAR;
VAR user, str: ARRAY 32 OF CHAR;
confPath, curPath, string : ARRAY 120 OF CHAR;
i : INTEGER;
f : Files.File;
r : Files.Rider;
ch : CHAR;
S: Texts.Scanner;
command : ARRAY 500 OF CHAR;
defaultUrl,project,command : ARRAY 500 OF CHAR;
PROCEDURE help();
BEGIN
vpkLogger.Log("HelpText");
END help;
BEGIN
(* Getting 1 argument and outputting it *)
Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos);
Texts.Scan(S);
Out.String(S.s); Out.Ln;
defaultUrl := "https://github.com/PizzaPablo666/test";
(* Vipack installation or help *)
command := S.s;
confPath := "/home//.vipack/";
(*HELP*)
IF Strings.Match(command, "") OR Strings.Match(command, "--help")THEN
help;
ELSIF Strings.Match(command, "install") THEN
vpkPackageFileParser.install();
END;
confPath := "/home//.vipack";
(* Getting username from input if there is no $USER variable *)
IF ~(vpkUserDetails.GetUsername(user)) THEN
Out.String("username: "); In.Line(user);
@ -45,22 +46,56 @@ 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 *)
IF ~(vpkFsHelper.mkDir(confPath)) THEN
Out.String(confPath); Out.String(" already exists or path is wrong");Out.Ln;
ELSE Out.String("Creating directory "); Out.String(confPath);Out.Ln;
IF vpkConf.makeDir(confPath) THEN
Out.String("Creating directory "); Out.String(confPath);Out.Ln;
ELSE Out.String(confPath); Out.String(" already exists or path is wrong");Out.Ln;
END;
(* Checking if vipack.conf already exists *)
Strings.Append(confFileName,confPath);
Strings.Append(confFileName,curPath);
IF ~(vpkConf.confExists(confPath)) THEN
Out.String("Creating the configuration file "); Out.String(confPath);Out.Ln;
vpkConf.makeConf(confPath);
IF ~(vpkConf.confExists(curPath)) THEN
Out.String("Creating the configuration file "); Out.String(confPath);Out.Ln;
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
Out.String("File already exists");Out.Ln;
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;
END main;

View file

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