Skip to content

Commit 8654ea0

Browse files
authored
CHORE: 0.3.0 pre-release (#11)
1 parent e1ec73b commit 8654ea0

File tree

13 files changed

+106
-32
lines changed

13 files changed

+106
-32
lines changed

README.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,26 @@ statloc project_name/
2424
```
2525

2626
```
27-
+-------------+-------+-------+
28-
| Item | LOC | Files |
29-
+-------------+-------+-------+
30-
| Go | 2339 | 27 |
31-
| Python | 10398 | 112 |
32-
| Rust | 970 | 11 |
33-
| Tests | 4612 | 43 |
34-
| Total | 13737 | 155 |
35-
+-------------+-------+-------+
27+
🗣️ Languages
28+
+--------+-----+-------+
29+
| Title | LOC | Files |
30+
+--------+-----+-------+
31+
| Python | 4 | 2 |
32+
| C++ | 8 | 2 |
33+
| Rust | 8 | 2 |
34+
| Go | 8 | 1 |
35+
+--------+-----+-------+
36+
37+
⚡ Components
38+
+-------------+-----+-------+
39+
| Title | LOC | Files |
40+
+-------------+-----+-------+
41+
| Tests | 10 | 3 |
42+
| Controllers | 8 | 2 |
43+
+-------------+-----+-------+
44+
45+
📊 Total statistics
46+
Languages: 4 LOC: 28 Files 7
3647
3748
```
3849

SECURITY.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
Here's a list of versions of the project are
66
currently being supported with security updates.
77

8-
9-
| Version | Supported |
10-
| ------- | ------------------ |
11-
| 0.1 | :white_check_mark: |
8+
| Version | Supported |
9+
| ------- | --------- |
10+
| 0.1 ||
11+
| 0.2 ||
12+
| 0.3 ||
1213

1314
#### ‼️ Reporting a Vulnerability
1415

cmd/main.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,17 @@ import (
44
"fmt"
55
"os"
66

7-
core "github.com/statloc/core"
8-
97
"cli/internal"
108
)
119

1210
func main () {
13-
if len(os.Args) != 2 {
11+
if len(os.Args) > 2 {
1412
fmt.Println("Error parsing argument: path specified incorrectly")
1513
} 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))
14+
path := "."
15+
if len(os.Args) == 2 {
16+
path = os.Args[1]
2317
}
18+
fmt.Print(internal.Respond(path))
2419
}
2520
}

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.3.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.3.0 h1:tJbgDGe5fvGt4tsmb0cKaAEV5VSGenJ61SrDdrAC2Xs=
558+
github.com/statloc/core v0.3.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: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,31 @@ import (
88
core "github.com/statloc/core"
99
)
1010

11+
func Respond(path string) (result string) {
12+
response, err := core.GetStatistics(path)
13+
14+
if err != nil {
15+
return fmt.Sprintf("ERROR: path \"%s\" is not found!!!\n", path)
16+
}
17+
18+
result = fmt.Sprintf(
19+
`🗣️ Languages
20+
%s
21+
⚡ Components
22+
%s
23+
📊 Total statistics
24+
Languages: %d LOC: %d Files %d
25+
`,
26+
GetTable(response.Languages, 5, 3, 5),
27+
GetTable(response.Components, 5, 3, 5),
28+
len(response.Languages),
29+
response.Total.LOC,
30+
response.Total.Files,
31+
)
32+
33+
return
34+
}
35+
1136
func GetTable(
1237
items map[string]*core.TableItem,
1338
titleLength int,

internal/utils_test.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,25 @@ import (
1111
"github.com/stretchr/testify/assert"
1212
)
1313

14-
func TestGetTable(t *testing.T) {
14+
func TestRespond(t *testing.T) {
1515
file, _ := os.Open("../testdata/results.txt")
1616
defer file.Close() // nolint:errcheck
1717

18+
response := internal.Respond("../testdata")
19+
20+
// go line by line
21+
scanner := bufio.NewScanner(file)
22+
for scanner.Scan() {
23+
assert.True(t, strings.Contains(response, scanner.Text()))
24+
}
25+
}
26+
27+
func TestGetTable(t *testing.T) {
28+
file, _ := os.Open("../testdata/languages.txt")
29+
defer file.Close() // nolint:errcheck
30+
1831
statistics, _ := core.GetStatistics("../testdata")
19-
table := internal.GetTable(statistics.Items, 5, 3, 5)
32+
table := internal.GetTable(statistics.Languages, 5, 3, 5)
2033

2134
// go line by line
2235
scanner := bufio.NewScanner(file)

testdata/languages.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
+--------+-----+-------+
2+
| Title | LOC | Files |
3+
+--------+-----+-------+
4+
| Rust | 8 | 2 |
5+
| Go | 8 | 1 |
6+
| Python | 4 | 2 |
7+
| C++ | 8 | 2 |
8+
+--------+-----+-------+

testdata/results.txt

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1+
🗣️ Languages
12
+--------+-----+-------+
23
| Title | LOC | Files |
34
+--------+-----+-------+
4-
| Tests | 6 | 2 |
5-
| Rust | 4 | 1 |
5+
| Rust | 8 | 2 |
66
| Go | 8 | 1 |
7-
| Python | 2 | 1 |
8-
| Total | 24 | 4 |
7+
| Python | 4 | 2 |
8+
| C++ | 8 | 2 |
99
+--------+-----+-------+
10+
11+
⚡ Components
12+
+-------------+-----+-------+
13+
| Title | LOC | Files |
14+
+-------------+-----+-------+
15+
| Tests | 10 | 3 |
16+
| Controllers | 8 | 2 |
17+
+-------------+-----+-------+
18+
19+
📊 Total statistics
20+
Languages: 4 LOC: 28 Files 7
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
int main() {
2+
return 0;
3+
}

0 commit comments

Comments
 (0)