Skip to content

Commit e75857a

Browse files
authored
feat: add function name keyword option (#129)
1 parent 2317931 commit e75857a

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

README.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ Also this tool can support output results **as a CSV file.**
5050
- The region to output is selected interactively and does not need to be specified.
5151
- -o, --output: optional
5252
- Output file path for CSV format
53+
- -k, --keyword: optional
54+
- Keyword for function name filtering (case-insensitive)
5355

5456
## Input flow
5557

@@ -59,6 +61,12 @@ Also this tool can support output results **as a CSV file.**
5961
❯ lamver
6062
```
6163

64+
You can specify `-k, --keyword` option. This is a keyword for **function name filtering (case-insensitive)**.
65+
66+
```sh
67+
❯ lamver -k goto
68+
```
69+
6270
### Choose regions
6371

6472
```sh
@@ -126,7 +134,9 @@ Also this tool can support output results **as a CSV file.**
126134

127135
You can search function names in a **case-insensitive**.
128136

129-
It can be **empty.**
137+
**Empty** input will output **all functions**.
138+
139+
This phase is skipped if you specify `-k` option.
130140

131141
```sh
132142
Filter a keyword of function names(case-insensitive): test-goto

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ require (
1313
github.com/olekukonko/tablewriter v0.0.5
1414
github.com/rs/zerolog v1.29.0
1515
github.com/urfave/cli/v2 v2.25.0
16+
go.uber.org/goleak v1.2.1
1617
golang.org/x/sync v0.3.0
1718
)
1819

@@ -36,7 +37,6 @@ require (
3637
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
3738
github.com/russross/blackfriday/v2 v2.1.0 // indirect
3839
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
39-
go.uber.org/goleak v1.2.1 // indirect
4040
golang.org/x/sys v0.1.0 // indirect
4141
golang.org/x/term v0.0.0-20210503060354-a79de5458b56 // indirect
4242
golang.org/x/text v0.3.7 // indirect

go.sum

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6us
7878
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
7979
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
8080
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
81-
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
8281
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
82+
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
8383
github.com/urfave/cli/v2 v2.25.0 h1:ykdZKuQey2zq0yin/l7JOm9Mh+pg72ngYMeB0ABn6q8=
8484
github.com/urfave/cli/v2 v2.25.0/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
8585
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=

internal/app/app.go

+18-6
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ import (
1818
const SDKRetryMaxAttempts = 3
1919

2020
type App struct {
21-
Cli *cli.App
22-
Profile string
23-
DefaultRegion string
24-
CSVOutputFilePath string
21+
Cli *cli.App
22+
Profile string
23+
DefaultRegion string
24+
CSVOutputFilePath string
25+
FunctionNameKeyword string
2526
}
2627

2728
func NewApp(version string) *App {
@@ -49,6 +50,12 @@ func NewApp(version string) *App {
4950
Usage: "Output file path for CSV format",
5051
Destination: &app.CSVOutputFilePath,
5152
},
53+
&cli.StringFlag{
54+
Name: "keyword",
55+
Aliases: []string{"k"},
56+
Usage: "Keyword for function name filtering (case-insensitive)",
57+
Destination: &app.FunctionNameKeyword,
58+
},
5259
},
5360
}
5461

@@ -107,8 +114,13 @@ func (a *App) getAction() func(c *cli.Context) error {
107114
return nil
108115
}
109116

110-
keywordLabel := "Filter a keyword of function names(case-insensitive): "
111-
keyword := io.InputKeywordForFilter(keywordLabel)
117+
var keyword string
118+
if a.FunctionNameKeyword != "" {
119+
keyword = a.FunctionNameKeyword
120+
} else {
121+
keywordLabel := "Filter a keyword of function names(case-insensitive): "
122+
keyword = io.InputKeywordForFilter(keywordLabel)
123+
}
112124

113125
createFunctionListInput := &action.CreateFunctionListInput{
114126
Ctx: c.Context,

0 commit comments

Comments
 (0)