Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.

Commit d8ddaf8

Browse files
committed
style: apply gofmt -s and translate CLI strings to English for A+ score
1 parent d4229c5 commit d8ddaf8

7 files changed

Lines changed: 36 additions & 40 deletions

File tree

internal/commands/format.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import (
1111

1212
const (
1313
formatUse = "format"
14-
formatShort = "Grupo de comandos para formatação de dados"
15-
16-
jsonUse = "json"
17-
jsonShort = "Formata um JSON para o padrão pretty-print"
18-
jsonLong = `Lê um JSON de um arquivo ou do stdin, valida sua estrutura e o imprime formatado no terminal.`
14+
formatShort = "Group of commands for data formatting"
15+
16+
jsonUse = "json"
17+
jsonShort = "Formats JSON to pretty-print standard"
18+
jsonLong = `Reads JSON from a file or stdin, validates its structure, and prints it formatted to the terminal.`
1919
)
2020

2121
var (
@@ -42,7 +42,7 @@ func init() {
4242
rootCmd.AddCommand(formatCmd)
4343
formatCmd.AddCommand(jsonCmd)
4444

45-
jsonCmd.Flags().StringVarP(&jsonFilePath, "file", "f", "", "Caminho do arquivo JSON para formatar")
45+
jsonCmd.Flags().StringVarP(&jsonFilePath, "file", "f", "", "JSON file path to format")
4646
}
4747

4848
func runFormatJSON() error {
@@ -59,7 +59,7 @@ func runFormatJSON() error {
5959
// Tentar ler do Stdin
6060
stat, _ := os.Stdin.Stat()
6161
if (stat.Mode() & os.ModeCharDevice) != 0 {
62-
return fmt.Errorf("nenhum input fornecido (use --file ou pipe o conteúdo via stdin)")
62+
return fmt.Errorf("no input provided (use --file or pipe content via stdin)")
6363
}
6464
input, err = io.ReadAll(os.Stdin)
6565
if err != nil {
@@ -76,7 +76,7 @@ func runFormatJSON() error {
7676
return nil
7777
}
7878

79-
// formatJSONBytes validates the input bytes as JSON and returns a
79+
// formatJSONBytes validates the input bytes as JSON and returns a
8080
// pretty-printed string. It returns an error if the input is not valid JSON.
8181
func formatJSONBytes(input []byte) (string, error) {
8282
// 2. Validar e Parsear JSON
@@ -101,11 +101,10 @@ func colorizeJSON(input string) string {
101101
// \x1b[34m = Blue (Keys), \x1b[32m = Green (Strings), \x1b[33m = Yellow (Numbers/Bools), \x1b[0m = Reset
102102
// Esta é uma implementação simplificada para evitar dependências externas e magic values brutos em excesso.
103103
// Em um sistema real, essas escapes estariam em tokens de sistema.
104-
105-
// Nota: Por simplicidade de código e robustez de entrega inicial,
104+
105+
// Nota: Por simplicidade de código e robustez de entrega inicial,
106106
// vamos retornar o JSON formatado. Colorização avançada exigiria um lexer.
107107
// Vou aplicar uma colorização básica via strings.Replace para as chaves.
108-
108+
109109
return input
110110
}
111-

internal/commands/ping.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,21 @@ import (
77
"sync"
88
"time"
99

10-
"github.com/charmbracelet/lipgloss"
11-
"github.com/charmbracelet/lipgloss/table"
1210
"github.com/ESousa97/go-cli-toolkit/internal/config"
1311
"github.com/ESousa97/go-cli-toolkit/internal/ui"
12+
"github.com/charmbracelet/lipgloss"
13+
"github.com/charmbracelet/lipgloss/table"
1414
"github.com/spf13/cobra"
1515
)
1616

1717
const (
18-
pingUse = "ping [url...]"
19-
pingShort = "Verifica se um ou mais hosts estão acessíveis"
20-
pingLong = `Verifica se as URLs informadas estão acessíveis através de uma requisição HTTP GET concorrente.
21-
Se nenhuma URL for passada, utiliza a lista de 'hosts favoritos' do config.yaml.`
18+
pingUse = "ping [url...]"
19+
pingShort = "Checks if one or more hosts are accessible"
20+
pingLong = `Checks if the provided URLs are accessible via concurrent HTTP GET requests.
21+
If no URLs are provided, it uses the 'favorite hosts' list from the configuration file.`
2222
pingTimeout = 5 * time.Second
2323
)
2424

25-
2625
type pingResult struct {
2726
url string
2827
online bool
@@ -42,7 +41,7 @@ var pingCmd = &cobra.Command{
4241
}
4342

4443
if len(targets) == 0 {
45-
return fmt.Errorf("nenhum host informado e nenhum host favorito encontrado no config.yaml")
44+
return fmt.Errorf("no host provided and no favorite hosts found in config repository")
4645
}
4746

4847
return runPing(targets)
@@ -71,7 +70,7 @@ func runPing(urls []string) error {
7170
close(resultsChan)
7271
}()
7372

74-
fmt.Printf("Iniciando ping em %d hosts...\n\n", len(urls))
73+
fmt.Printf("Starting ping for %d hosts...\n\n", len(urls))
7574

7675
t := table.New().
7776
Border(lipgloss.NormalBorder()).
@@ -139,4 +138,3 @@ func pingHostConcurrently(targetURL string) pingResult {
139138

140139
return pingResult{url: targetURL, online: false, status: resp.StatusCode, message: "status code inválido"}
141140
}
142-

internal/commands/ping_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func TestPingHostConcurrently(t *testing.T) {
5050
for _, tt := range tests {
5151
t.Run(tt.name, func(t *testing.T) {
5252
res := pingHostConcurrently(tt.targetURL)
53-
53+
5454
assert.Equal(t, tt.targetURL, res.url, "A URL de resposta deve ser a mesma.")
5555
assert.Equal(t, tt.wantOnline, res.online, "O status online retornado divergiu.")
5656
assert.Equal(t, tt.wantStatus, res.status, "O Http StatusCode retornado divergiu.")

internal/commands/root.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import (
77

88
const (
99
toolkitUse = "toolkit"
10-
toolkitShort = "Toolkit é uma CLI utilitária"
11-
toolkitLong = `Toolkit é uma Interface de Linha de Comando (CLI) utilitária em Go.
12-
Use os subcomandos para iterar sobre as funcionalidades disponíveis.`
10+
toolkitShort = "A utility CLI toolkit written in Go"
11+
toolkitLong = `Toolkit is a command-line interface (CLI) with utilities for network diagnostics
12+
and data manipulation. Use the available subcommands to interact with the features.`
1313
)
1414

1515
// rootCmd representa o comando base quando chamado sem subcomandos
@@ -34,4 +34,3 @@ func init() {
3434
}
3535
})
3636
}
37-

internal/config/config_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import (
55
"path/filepath"
66
"testing"
77

8-
"github.com/stretchr/testify/assert"
98
"github.com/spf13/viper"
9+
"github.com/stretchr/testify/assert"
1010
)
1111

1212
func TestInitConfig(t *testing.T) {
1313
// Preparar um diretório temporário para atuar como ambiente de teste
1414
tempDir := t.TempDir()
15-
15+
1616
// Alterar o diretório de trabalho apenas para o escopo desse teste
1717
// para que o viper procure o config.yaml aqui.
1818
originalWd, _ := os.Getwd()
@@ -37,7 +37,7 @@ func TestInitConfig(t *testing.T) {
3737

3838
err = InitConfig()
3939
assert.NoError(t, err, "Não deveria haver erro ao carregar config válido")
40-
40+
4141
conf := GetConfig()
4242
assert.Len(t, conf.Hosts, 2)
4343
assert.Equal(t, "test.com", conf.Hosts[0])

internal/ui/styles.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import "github.com/charmbracelet/lipgloss"
44

55
var (
66
// Standard color tokens for the design system.
7-
ColorPrimary = lipgloss.Color("63") // Roxo/Azul premium
8-
ColorSuccess = lipgloss.Color("42") // Verde vibrante
9-
ColorError = lipgloss.Color("196") // Vermelho vibrante
10-
ColorGray = lipgloss.Color("240")
11-
ColorWhite = lipgloss.Color("255")
7+
ColorPrimary = lipgloss.Color("63") // Roxo/Azul premium
8+
ColorSuccess = lipgloss.Color("42") // Verde vibrante
9+
ColorError = lipgloss.Color("196") // Vermelho vibrante
10+
ColorGray = lipgloss.Color("240")
11+
ColorWhite = lipgloss.Color("255")
1212
)
1313
var (
1414
// HeaderStyle defines the visual style for table headers.

internal/ui/styles_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ import (
77
)
88

99
func TestStylesInitialization(t *testing.T) {
10-
// Como styles.go define apenas variáveis e constantes de estilo,
11-
// um teste básico é garantir que eles foram renderizados/carregados sem panic.
10+
// styles.go defines variables and style constants,
11+
// a basic test ensures they are loaded/rendered without panic.
1212

1313
// Verifica se as cores não estão vazias internamente
1414
assert.NotNil(t, ColorPrimary)
1515
assert.NotNil(t, ColorSuccess)
1616
assert.NotNil(t, ColorError)
17-
17+
1818
// Verifica a renderização das constantes de status
19-
assert.Contains(t, StatusOkText, "ONLINE", "A constante de sucesso deve conter texto ONLINE")
20-
assert.Contains(t, StatusFailText, "OFFLINE", "A constante de erro deve conter texto OFFLINE")
19+
assert.Contains(t, StatusOkText, "ONLINE", "Success constant should contain ONLINE text")
20+
assert.Contains(t, StatusFailText, "OFFLINE", "Error constant should contain OFFLINE text")
2121

2222
// Como é UI, a lógica aqui é mais para cobrir a sintaxe Go e evitar regressões
2323
// que quebrem a compilação por erros de tipo.

0 commit comments

Comments
 (0)