Skip to content

Commit

Permalink
sáb 07 out 2023 02:19:15 -04 Vilmar Catafesta ([email protected])
Browse files Browse the repository at this point in the history
  • Loading branch information
vcatafesta committed Oct 7, 2023
1 parent de3c033 commit 2de9a33
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
Binary file modified usr/bin/big-pacman-to-json
Binary file not shown.
23 changes: 9 additions & 14 deletions usr/src/bigcontrolcenter-base/go/big-pacman-to-json.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,20 @@ func ProcessOutput(input, xcmd string) {
// Variáveis para manter as informações do pacote
var packages []PackageInfo
var currentPackage PackageInfo
isDescription := false
isName := false
IsDescription := false
IsName := false

// Divide o texto de entrada em linhas
lines := strings.Split(input, "\n")

// Processa cada linha da entrada
for _, line := range lines {
// Verifica se a linha começa com 2 espaços iniciais (indica descrição)
if strings.HasPrefix(line, " ") {
if strings.HasPrefix(line, " ") && IsName == true {
line = strings.TrimSpace(line)
currentPackage.Description += line
isDescription = true
} else {
IsDescription = true
} else if IsName == false {
// Divide a linha em campos e verifica se há pelo menos 2 campos (nome e versão)
fields := strings.Fields(line)
if len(fields) >= 1 {
Expand Down Expand Up @@ -134,20 +134,15 @@ func ProcessOutput(input, xcmd string) {
currentPackage.Status = fields[2]
}
}
isName = true
IsName = true
}
}
// Se a linha não começar com 2 espaços, isso indica o início de um novo pacote
if isDescription == true && isName == true {
if IsDescription == true && IsName == true {
packages = append(packages, currentPackage)
currentPackage = PackageInfo{}
isDescription = false
isName = false
} else if isName == true {
packages = append(packages, currentPackage)
currentPackage = PackageInfo{}
isDescription = false
isName = false
IsDescription = false
IsName = false
}
}

Expand Down

0 comments on commit 2de9a33

Please sign in to comment.