Skip to content

Commit 751ad49

Browse files
committed
1 parent e1ec73b commit 751ad49

6 files changed

Lines changed: 37 additions & 20 deletions

File tree

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ currently being supported with security updates.
88

99
| Version | Supported |
1010
| ------- | ------------------ |
11-
| 0.1 | :white_check_mark: |
11+
| 0.2 | :white_check_mark: |
1212

1313
#### ‼️ Reporting a Vulnerability
1414

cmd/main.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,10 @@ package main
22

33
import (
44
"fmt"
5-
"os"
6-
7-
core "github.com/statloc/core"
85

96
"cli/internal"
107
)
118

129
func main () {
13-
if len(os.Args) != 2 {
14-
fmt.Println("Error parsing argument: path specified incorrectly")
15-
} else {
16-
path := os.Args[1]
17-
response, err := core.GetStatistics(path)
18-
19-
if err != nil {
20-
fmt.Printf("ERROR: path \"%s\" is not found!!!\n", path)
21-
} else {
22-
fmt.Print(internal.GetTable(response.Items, 5, 3, 5))
23-
}
24-
}
10+
fmt.Print(internal.Respond())
2511
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module cli
33
go 1.25.1
44

55
require (
6-
github.com/statloc/core v0.1.1
6+
github.com/statloc/core v0.2.0
77
github.com/stretchr/testify v1.11.1
88
)
99

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,8 @@ github.com/spf13/viper v1.12.0 h1:CZ7eSOd3kZoaYDLbXnmzgQI5RlciuXBMA+18HwHRfZQ=
554554
github.com/spf13/viper v1.12.0/go.mod h1:b6COn30jlNxbm/V2IqWiNWkJ+vZNiMNksliPCiuKtSI=
555555
github.com/ssgreg/nlreturn/v2 v2.2.1 h1:X4XDI7jstt3ySqGU86YGAURbxw3oTDPK9sPEi6YEwQ0=
556556
github.com/ssgreg/nlreturn/v2 v2.2.1/go.mod h1:E/iiPB78hV7Szg2YfRgyIrk1AD6JVMTRkkxBiELzh2I=
557-
github.com/statloc/core v0.1.1 h1:P14Zwr1335qsjrwb5r5vtN9VQMhhPCccN3pVraQ5ooY=
558-
github.com/statloc/core v0.1.1/go.mod h1:wSaKZ/WZpoghw/PGmI54rBb5PfBxoESkRH2EesFUrn0=
557+
github.com/statloc/core v0.2.0 h1:VjFxY42HONSXEK7L6g51RoMU5bWelkgKQYV4U/jyVE8=
558+
github.com/statloc/core v0.2.0/go.mod h1:wSaKZ/WZpoghw/PGmI54rBb5PfBxoESkRH2EesFUrn0=
559559
github.com/stbenjam/no-sprintf-host-port v0.2.0 h1:i8pxvGrt1+4G0czLr/WnmyH7zbZ8Bg8etvARQ1rpyl4=
560560
github.com/stbenjam/no-sprintf-host-port v0.2.0/go.mod h1:eL0bQ9PasS0hsyTyfTjjG+E80QIyPnBVQbYZyv20Jfk=
561561
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=

internal/utils.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,43 @@ package internal
22

33
import (
44
"fmt"
5+
"os"
56
"strconv"
67
"strings"
78

89
core "github.com/statloc/core"
910
)
1011

12+
func Respond() string {
13+
if len(os.Args) != 2 {
14+
return "Error parsing argument: path specified incorrectly"
15+
} else {
16+
path := os.Args[1]
17+
response, err := core.GetStatistics(path)
18+
19+
if err != nil {
20+
return fmt.Sprintf("ERROR: path \"%s\" is not found!!!\n", path)
21+
}
22+
23+
result := fmt.Sprintf(
24+
`🗣️ Languages
25+
%s
26+
⚡ Components
27+
%s
28+
📊 Total statistics
29+
Languages: %d LOC: %d Files %d
30+
`,
31+
GetTable(response.Languages, 5, 3, 5),
32+
GetTable(response.Components, 5, 3, 5),
33+
len(response.Languages),
34+
response.Total.LOC,
35+
response.Total.Files,
36+
)
37+
38+
return result
39+
}
40+
}
41+
1142
func GetTable(
1243
items map[string]*core.TableItem,
1344
titleLength int,

internal/utils_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func TestGetTable(t *testing.T) {
1616
defer file.Close() // nolint:errcheck
1717

1818
statistics, _ := core.GetStatistics("../testdata")
19-
table := internal.GetTable(statistics.Items, 5, 3, 5)
19+
table := internal.GetTable(statistics.Languages, 5, 3, 5)
2020

2121
// go line by line
2222
scanner := bufio.NewScanner(file)

0 commit comments

Comments
 (0)