@@ -40,7 +40,7 @@ func resolveContentType(fileExtensionOrContentType string) runner.MimeType {
40
40
return runner .GetMimeType ("x." + fileExtensionOrContentType , runner.ContentTypeInfo {})
41
41
}
42
42
43
- func evalFileInto (file , mimetype string , out * os.File ) error {
43
+ func evalFileInto (file , mimetype string , convertNumbers bool , out * os.File ) error {
44
44
if mimetype == "" {
45
45
mimetype = string (runner .GetMimeType (file , runner.ContentTypeInfo {}))
46
46
} else {
@@ -55,7 +55,8 @@ func evalFileInto(file, mimetype string, out *os.File) error {
55
55
defer w .Flush ()
56
56
57
57
return runner .TransformFile (file , runner.ContentTypeInfo {
58
- Type : mimetype ,
58
+ Type : mimetype ,
59
+ ConvertNumbers : convertNumbers ,
59
60
}, w )
60
61
}
61
62
@@ -213,7 +214,7 @@ func getFilesContentHash(files []string) (string, error) {
213
214
return hex .EncodeToString (sha1 .Sum (nil )), nil
214
215
}
215
216
216
- func importFile (projectId string , file , mimetype string , ec runner.EvalContext ) (* runner.PanelInfo , error ) {
217
+ func importFile (projectId string , file , mimetype string , convertNumbers bool , ec runner.EvalContext ) (* runner.PanelInfo , error ) {
217
218
panelId := uuid .New ().String ()
218
219
resultFile := ec .GetPanelResultsFile (projectId , panelId )
219
220
out , err := openTruncate (resultFile )
@@ -222,7 +223,7 @@ func importFile(projectId string, file, mimetype string, ec runner.EvalContext)
222
223
}
223
224
defer out .Close ()
224
225
225
- if err := evalFileInto (file , mimetype , out ); err != nil {
226
+ if err := evalFileInto (file , mimetype , convertNumbers , out ); err != nil {
226
227
return nil , err
227
228
}
228
229
@@ -333,14 +334,15 @@ func repl(project *runner.ProjectState, ec *runner.EvalContext, args *args, file
333
334
}
334
335
335
336
type args struct {
336
- pipedMimetype string
337
- pretty bool
338
- schema bool
339
- sqlFile string
340
- cacheSettings runner.CacheSettings
341
- nonFlagArgs []string
342
- dumpCacheFile bool
343
- isInteractive bool
337
+ pipedMimetype string
338
+ pretty bool
339
+ schema bool
340
+ sqlFile string
341
+ cacheSettings runner.CacheSettings
342
+ nonFlagArgs []string
343
+ dumpCacheFile bool
344
+ isInteractive bool
345
+ convertNumbers bool
344
346
}
345
347
346
348
func getArgs () (* args , error ) {
@@ -415,6 +417,11 @@ func getArgs() (*args, error) {
415
417
continue
416
418
}
417
419
420
+ if arg == "-n" || arg == "--convert-numbers" {
421
+ args .convertNumbers = true
422
+ continue
423
+ }
424
+
418
425
args .nonFlagArgs = append (args .nonFlagArgs , arg )
419
426
}
420
427
@@ -558,7 +565,7 @@ func _main() error {
558
565
// When dumping schema, need to injest even if cache is on.
559
566
if ! args .cacheSettings .CachePresent || ! args .cacheSettings .Enabled || lastNonFlagArg == "" {
560
567
for _ , file := range files {
561
- panel , err := importFile (project .Id , file , mimetypeOverride [file ], ec )
568
+ panel , err := importFile (project .Id , file , mimetypeOverride [file ], args . convertNumbers , ec )
562
569
if err != nil {
563
570
return err
564
571
}
0 commit comments