Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
Grey Hack
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de conteneur
Registre de modèles
Opération
Environnements
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Qu'est-ce que Tu GEEKes ?
Grey Hack
Validations
6e5f7f31
Valider
6e5f7f31
rédigé
4 years ago
par
LaplongeJunior
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Changed to use shellapi
parent
8b85b198
Aucune branche associée trouvée
Branches contenant la validation
Aucune étiquette associée trouvée
Chargement en cours
Modifications
1
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
scripts/libs/vshell.inc.src
+31
-64
31 ajouts, 64 suppressions
scripts/libs/vshell.inc.src
avec
31 ajouts
et
64 suppressions
scripts/libs/vshell.inc.src
+
31
−
64
Voir le fichier @
6e5f7f31
...
...
@@ -4,53 +4,34 @@
"#import libs/utils.inc.src"
"#import libs/file.inc.src"
"#import libs/shellapi.inc.src"
"#ifbuild"
if not globals.hasIndex("imports") then imports = {}
imports.temp = {}
"#endif"
imports.vshell = {}
"#ifbuild"
vshell = imports.vshell
"#endif"
imports.shellapi.vshell = {}
imports.vshell.EXIT = "exit"
imports.vshell.constrs = {}
imports.shellapi.vshell.navigate = function(file, target)
originSteps = file.path.split("/")
targetSteps = file.path.split("/")
// TODO: File navigation
return null
end function
imports.vshell.constrs.shell = function(object)
result = {}
imports.shellapi.vshell.init = function(object)
if typeof(object) == "shell" then object = object.host_computer
type = typeof(object)
if type != "computer" and type != "file" then return null
result.start_terminal = function()
while true
print("Please enter a command:"+imports.file.NEW_LINE)
command = user_prompt().split(" ")
if command[0] == imports.vshell.EXIT then break
cmd = imports.utils.SafeMapAccess(imports.vshell.cmds,command[0])
if cmd == null then
print(cmd+ " is not a recognized command")
return
end if
// Remove the command name
params = []
for i in range(1,command.len-1)
params.push(command[i])
end for
heart = result.heart
current_path = result.current_path
result = cmd(self, params)
if result and typeof(result) != "function" then
print(command[0] +" error: "+result)
// Rollback
result.heart = heart
result.current_path = current_path
end if
end while
result = imports.shellapi.constrs.shellui(imports.shellapi.vshell.cmds)
// Add support for command errors
result.transaction = function()
return [self.heart, self.current_path]
end function
result.rollback = function(transaction)
result.heart = transaction[0]
result.current_path = transaction[1]
end function
// Add vshell-specific inner functionalities
result.navigate = function(path)
isFile = typeof(self.heart) == "file"
if not path then
...
...
@@ -82,41 +63,27 @@ imports.vshell.constrs.shell = function(object)
end function
result.heart = object
// Init the current_path var
if typeof(object) == "file" then path = object.path else path = object.current_path
result.navigate(path)
return result
end function
imports.vshell.navigate = function(file, target)
originSteps = file.path.split("/")
targetSteps = file.path.split("/")
// TODO: File navigation
return null
end function
imports.vshell.init = function(object)
if typeof(object) == "shell" then object = object.host_computer
type = typeof(object)
if type != "computer" and type != "file" then return null
return imports.vshell.constrs.shell(object)
end function
imports.vshell.run = function(object)
imports.shellapi.vshell.run = function(object)
imports.vshell.init(object).start_terminal()
end function
imports.vshell.read = function(shell, params)
imports.
shellapi.
vshell.read = function(shell, params)
if params.len > 0 then return "Parameter required"
file = shell.navigate(params[0])
// TODO: File reading
end function
imports.vshell.cmds = {}
imports.
shellapi.
vshell.cmds = {}
imports.vshell.cmds.help = function(shell, params)
imports.
shellapi.
vshell.cmds.help = function(shell, params)
names = ["exit"]
for name in imports.vshell.cmds.values
names.put(name)
...
...
@@ -125,7 +92,7 @@ imports.vshell.cmds.help = function(shell, params)
print(imports.utils.PrintList(names,imports.file.NEW_LINE))
end function
imports.vshell.cmds.cd = function(shell, params)
imports.
shellapi.
vshell.cmds.cd = function(shell, params)
if params.len == 0 then path = "" else path = params[0]
if not shell.navigate(path).is_folder then return "target is not a folder!"
...
...
@@ -141,19 +108,19 @@ imports.vshell.cmds.cd = function(shell, params)
print(imports.utils.PrintList(names,imports.file.NEW_LINE))
end function
imports.vshell.cmds.read = function(shell, params)
imports.
shellapi.
vshell.cmds.read = function(shell, params)
result = imports.vshell.read(shell,params)
if typeof(result) != "list" then return result
print(imports.utils.PrintList(result,imports.file.NEW_LINE))
end function
imports.vshell.cmds.get = function(shell, params)
imports.
shellapi.
vshell.cmds.get = function(shell, params)
result = imports.vshell.read(shell,params)
if typeof(result) != "list" then return result
content = imports.utils.PrintList(result,imports.file.NEW_LINE)
end function
imports.vshell.cmds.delete = function(shell, params)
imports.
shellapi.
vshell.cmds.delete = function(shell, params)
if params.len > 0 then return "Parameter required"
file = shell.navigate(params[0])
if not imports.utils.UserPrompt("Do you *REALLY* want to delete '"+file.path+"' ?") then return "Execution cancelled by user"
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter