feat: add version command
This commit is contained in:
		
							
								
								
									
										3
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							@@ -16,6 +16,9 @@ jobs:
 | 
			
		||||
      - name: checkout repository
 | 
			
		||||
        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
 | 
			
		||||
        uses: actions/setup-go@v4
 | 
			
		||||
        with:
 | 
			
		||||
 
 | 
			
		||||
@@ -33,10 +33,13 @@ esgo2dump --input=http://127.0.0.1:9200/some_index --output=./data.json --query_
 | 
			
		||||
	f_query  string
 | 
			
		||||
 | 
			
		||||
	f_query_file string
 | 
			
		||||
 | 
			
		||||
	f_version bool
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	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().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)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if f_version {
 | 
			
		||||
		logrus.Infof("esgo2dump (Version: %s)", opt.Version)
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err = check(cmd); err != nil {
 | 
			
		||||
		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"
 | 
			
		||||
		Reference in New Issue
	
	Block a user