Some Changes

This commit is contained in:
Alexandre 2025-02-03 09:14:36 +01:00
parent 049e3218f3
commit d3da40abd3
3 changed files with 14 additions and 1 deletions

1
go.mod
View File

@ -6,6 +6,7 @@ require (
github.com/chzyer/readline v1.5.1 // indirect
github.com/creack/pty v1.1.24 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect

2
go.sum
View File

@ -8,6 +8,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=

12
main.go
View File

@ -10,6 +10,7 @@ import (
"github.com/chzyer/readline"
"github.com/creack/pty"
"github.com/google/shlex"
"github.com/spf13/viper"
)
@ -136,7 +137,16 @@ func getPrompt() string {
func execInput(input string) error {
input = strings.TrimSuffix(input, "\n")
args := strings.Split(input, " ")
// Diviser la commande en arguments en respectant les guillemets
args, err := shlex.Split(input)
if err != nil {
return fmt.Errorf("Erreur lors de la division des arguments: %v", err)
}
if len(args) == 0 {
return nil
}
// Gérer les commandes intégrées
switch args[0] {