Skip to content

Commit 625ae70

Browse files
Walzpierrelalanne
authored andcommitted
feat(cli): move --verbose and --debug to global options
1 parent 083229d commit 625ae70

File tree

3 files changed

+27
-25
lines changed

3 files changed

+27
-25
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ It reads from CLI and environment the configuration and run the Pipeline on an o
4444

4545
- Run on a given user/group
4646
```sh
47-
./src-fingerprint --provider github --object Uber
48-
./src-fingerprint --provider-url http://gitlab.example.com --provider gitlab --object Groupe
47+
./src-fingerprint collect --provider github --object Uber
48+
./src-fingerprint collect --provider-url http://gitlab.example.com --provider gitlab --object Groupe
4949
```
5050

5151
## Performance considerations

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,41 +127,41 @@ Note that by default, `src-fingerprint` will exclude forked repositories from th
127127
1. Export all fingerprints from private repositories from a GitHub Org to the default path `./fingerprints.jsonl.gz` with logs:
128128

129129
```sh
130-
env VCS_TOKEN="<token>" src-fingerprint -v --provider github --object ORG_NAME
130+
env VCS_TOKEN="<token>" src-fingerprint -v collect --provider github --object ORG_NAME
131131
```
132132

133133
2. Export all fingerprints of every repository the user can access to the default path `./fingerprints.jsonl.gz`:
134134

135135
```sh
136-
env VCS_TOKEN="<token>" src-fingerprint -v --provider github --include-public-repos --include-forked-repos --include-archived-repos
136+
env VCS_TOKEN="<token>" src-fingerprint -v collect --provider github --include-public-repos --include-forked-repos --include-archived-repos
137137
```
138138

139139
### GitLab
140140

141141
1. Export all fingerprints from private repositories of a GitLab group to the default path `./fingerprints.jsonl.gz` with logs:
142142

143143
```sh
144-
env VCS_TOKEN="<token>" src-fingerprint -v --provider gitlab --object "GitGuardian-dev-group"
144+
env VCS_TOKEN="<token>" src-fingerprint -v collect --provider gitlab --object "GitGuardian-dev-group"
145145
```
146146

147147
2. Export all fingerprints of every project the user can access to the default path `./fingerprints.jsonl.gz` with logs:
148148

149149
```sh
150-
env VCS_TOKEN="<token>" src-fingerprint -v --provider gitlab --include-forked-repos
150+
env VCS_TOKEN="<token>" src-fingerprint -v collect --provider gitlab --include-forked-repos
151151
```
152152

153153
### Bitbucket server (formely Atlassian Stash)
154154

155155
1. Export all fingerprints from a Bitbucket project with private repository to the default path `./fingerprints.jsonl.gz` with logs:
156156

157157
```sh
158-
env VCS_TOKEN="<token>" src-fingerprint -v --provider bitbucket --object "GitGuardian Project"
158+
env VCS_TOKEN="<token>" src-fingerprint -v collect --provider bitbucket --object "GitGuardian Project"
159159
```
160160

161161
2. Export all fingerprints of every repository the user can access to the default path `./fingerprints.jsonl.gz` with logs:
162162

163163
```sh
164-
env VCS_TOKEN="<token>" src-fingerprint -v --provider bitbucket
164+
env VCS_TOKEN="<token>" src-fingerprint -v collect --provider bitbucket
165165
```
166166

167167
### Repository

cmd/src-fingerprint/main.go

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,20 @@ func main() {
9191
Name: "src-fingerprint",
9292
Version: version,
9393
Usage: "src-fingerprint is a tool to collect and manipulate source code fingerprints.",
94+
Before: beforeAction,
95+
Flags: []cli.Flag{
96+
&cli.BoolFlag{
97+
Name: "verbose",
98+
Aliases: []string{"v"},
99+
Value: false,
100+
Usage: "Run with verbose logging",
101+
},
102+
&cli.BoolFlag{
103+
Name: "debug",
104+
Value: false,
105+
Usage: "Run with debug logging, override verbose",
106+
},
107+
},
94108
Commands: []*cli.Command{
95109
{
96110
Name: "collect",
@@ -112,22 +126,6 @@ func main() {
112126
Aliases: []string{"u"},
113127
Usage: "repository|org|group to scrape. If not specified all reachable repositories will be collected.",
114128
},
115-
&cli.BoolFlag{
116-
Name: "verbose",
117-
Aliases: []string{"v"},
118-
Value: false,
119-
Usage: "Run with verbose logging",
120-
},
121-
&cli.BoolFlag{
122-
Name: "debug",
123-
Value: false,
124-
Usage: "debug logging, override verbose",
125-
},
126-
&cli.BoolFlag{
127-
Name: "debug",
128-
Value: false,
129-
Usage: "Run with debug logging, overrides verbose",
130-
},
131129
&cli.BoolFlag{
132130
Name: "include-forked-repos",
133131
Value: false,
@@ -200,7 +198,7 @@ func main() {
200198
}
201199
}
202200

203-
func collectAction(c *cli.Context) error {
201+
func beforeAction(c *cli.Context) error {
204202
if c.Bool("debug") {
205203
log.SetLevel(log.DebugLevel)
206204
} else if c.Bool("verbose") {
@@ -209,6 +207,10 @@ func collectAction(c *cli.Context) error {
209207
log.SetLevel(log.WarnLevel)
210208
}
211209

210+
return nil
211+
}
212+
213+
func collectAction(c *cli.Context) error {
212214
output := os.Stdout
213215
fsOutput := false
214216

0 commit comments

Comments
 (0)