feat: add version command
This commit is contained in:
parent
5acad1096f
commit
eb97f7b0a3
3
.github/workflows/build.yml
vendored
3
.github/workflows/build.yml
vendored
@ -16,6 +16,9 @@ jobs:
|
|||||||
- name: checkout repository
|
- name: checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: fill version
|
||||||
|
run: sed -i -E "s/v[0-9]+.[0-9]+.[0-9]+/${{ github.ref_name }}/g" internal/opt/version.go
|
||||||
|
|
||||||
- name: install golang
|
- name: install golang
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
|
@ -33,10 +33,13 @@ esgo2dump --input=http://127.0.0.1:9200/some_index --output=./data.json --query_
|
|||||||
f_query string
|
f_query string
|
||||||
|
|
||||||
f_query_file string
|
f_query_file string
|
||||||
|
|
||||||
|
f_version bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCommand.Flags().BoolVar(&opt.Debug, "debug", false, "")
|
rootCommand.Flags().BoolVar(&opt.Debug, "debug", false, "")
|
||||||
|
rootCommand.Flags().BoolVarP(&f_version, "version", "v", false, "print esgo2dump version")
|
||||||
rootCommand.Flags().IntVar(&opt.Timeout, "timeout", 30, "max timeout seconds per operation with limit")
|
rootCommand.Flags().IntVar(&opt.Timeout, "timeout", 30, "max timeout seconds per operation with limit")
|
||||||
|
|
||||||
rootCommand.Flags().StringVarP(&f_input, "input", "i", "", "*required: input file or es url (example :data.json / http://127.0.0.1:9200/my_index)")
|
rootCommand.Flags().StringVarP(&f_input, "input", "i", "", "*required: input file or es url (example :data.json / http://127.0.0.1:9200/my_index)")
|
||||||
|
@ -50,6 +50,11 @@ func run(cmd *cobra.Command, args []string) error {
|
|||||||
logrus.SetLevel(logrus.DebugLevel)
|
logrus.SetLevel(logrus.DebugLevel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if f_version {
|
||||||
|
logrus.Infof("esgo2dump (Version: %s)", opt.Version)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if err = check(cmd); err != nil {
|
if err = check(cmd); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
3
internal/opt/version.go
Normal file
3
internal/opt/version.go
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
package opt
|
||||||
|
|
||||||
|
const Version = "v0.1.2"
|
Loading…
x
Reference in New Issue
Block a user