Skip to content

Commit 9e837e6

Browse files
author
Alvaro Muñoz
committed
update README
1 parent 388b0ef commit 9e837e6

File tree

2 files changed

+53
-53
lines changed

2 files changed

+53
-53
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Available Commands:
3535
download Downloads a CodeQL database from GitHub Code Scanning
3636
help Help about any command
3737
install Install a local CodeQL database in the QLDB directory
38-
path Returns the path to a database stored in the QLDB structure
38+
info Returns information about a database stored in the QLDB structure
3939

4040
Flags:
4141
-h, --help help for gh-qldb
@@ -64,7 +64,7 @@ gh qldb install -d path/to/database -n apache/logging-log4j2
6464
#### Get information about a database
6565

6666
```bash
67-
gh qldb path -n apache/logging-log4j2 -l java -j
67+
gh qldb info -n apache/logging-log4j2 -l java -j
6868
[
6969
{
7070
"commitSha": "fa2f51e",

cmd/info.go

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,62 @@
11
package cmd
22

33
import (
4-
"github.com/GitHubSecurityLab/gh-qldb/utils"
5-
"github.com/spf13/cobra"
6-
"path/filepath"
7-
"log"
8-
"fmt"
9-
"io/ioutil"
10-
"encoding/json"
4+
"encoding/json"
5+
"fmt"
6+
"github.com/GitHubSecurityLab/gh-qldb/utils"
7+
"github.com/spf13/cobra"
8+
"io/ioutil"
9+
"log"
10+
"path/filepath"
1111
)
12+
1213
var infoCmd = &cobra.Command{
13-
Use: "info",
14-
Short: "Returns information for a database stored in the QLDB structure",
15-
Long: `Returns information for a database stored in the QLDB structure`,
16-
Run: func(cmd *cobra.Command, args []string) {
17-
info(nwoFlag, languageFlag)
18-
},
19-
}
14+
Use: "info",
15+
Short: "Returns information about a database stored in the QLDB structure",
16+
Long: `Returns information about a database stored in the QLDB structure`,
17+
Run: func(cmd *cobra.Command, args []string) {
18+
info(nwoFlag, languageFlag)
19+
},
20+
}
2021

2122
func init() {
22-
rootCmd.AddCommand(infoCmd)
23-
infoCmd.Flags().StringVarP(&nwoFlag, "nwo", "n", "", "The NWO of the repository to get the database for.")
24-
infoCmd.Flags().StringVarP(&languageFlag, "language", "l", "", "The primary language you want the database for.")
25-
infoCmd.Flags().BoolVarP(&jsonFlag, "json", "j", false, "Use json as the output format.")
26-
infoCmd.MarkFlagRequired("nwo")
27-
infoCmd.MarkFlagRequired("language")
23+
rootCmd.AddCommand(infoCmd)
24+
infoCmd.Flags().StringVarP(&nwoFlag, "nwo", "n", "", "The NWO of the repository to get the database for.")
25+
infoCmd.Flags().StringVarP(&languageFlag, "language", "l", "", "The primary language you want the database for.")
26+
infoCmd.Flags().BoolVarP(&jsonFlag, "json", "j", false, "Use json as the output format.")
27+
infoCmd.MarkFlagRequired("nwo")
28+
infoCmd.MarkFlagRequired("language")
2829
}
2930

3031
func info(nwo string, language string) {
31-
dir := filepath.Join(utils.GetPath(nwo), language)
32-
files, err := ioutil.ReadDir(dir)
33-
if err != nil {
34-
log.Fatal(err)
35-
}
36-
var pathList []map[string]string
37-
for _, f := range files {
38-
filename := f.Name()
39-
sha := filename[:len(filename)-len(filepath.Ext(filename))]
40-
commitSha, committedDate, err := utils.GetCommitInfo(nwo, sha)
41-
if err != nil {
42-
log.Fatal(err)
43-
}
44-
pathList = append(pathList, map[string]string{
45-
"commitSha": commitSha,
46-
"committedDate": committedDate,
47-
"path": filepath.Join(dir, filename),
48-
})
49-
}
50-
if jsonFlag {
51-
jsonStr, err := json.MarshalIndent(pathList, "", " ")
52-
if err != nil {
53-
log.Fatal(err)
54-
}
55-
fmt.Printf("%s", jsonStr)
56-
} else {
57-
for _, path := range pathList {
58-
fmt.Printf("%s (%s)", path["path"], path["committedDate"])
59-
}
60-
}
32+
dir := filepath.Join(utils.GetPath(nwo), language)
33+
files, err := ioutil.ReadDir(dir)
34+
if err != nil {
35+
log.Fatal(err)
36+
}
37+
var pathList []map[string]string
38+
for _, f := range files {
39+
filename := f.Name()
40+
sha := filename[:len(filename)-len(filepath.Ext(filename))]
41+
commitSha, committedDate, err := utils.GetCommitInfo(nwo, sha)
42+
if err != nil {
43+
log.Fatal(err)
44+
}
45+
pathList = append(pathList, map[string]string{
46+
"commitSha": commitSha,
47+
"committedDate": committedDate,
48+
"path": filepath.Join(dir, filename),
49+
})
50+
}
51+
if jsonFlag {
52+
jsonStr, err := json.MarshalIndent(pathList, "", " ")
53+
if err != nil {
54+
log.Fatal(err)
55+
}
56+
fmt.Printf("%s", jsonStr)
57+
} else {
58+
for _, path := range pathList {
59+
fmt.Printf("%s (%s)", path["path"], path["committedDate"])
60+
}
61+
}
6162
}
62-

0 commit comments

Comments
 (0)