diff --git a/README.md b/README.md index 0a3f8ad..bdad478 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ $ make install #### 1.1.1. Requirements -go 1.17 or higher. +go 1.18 or higher. ### 1.2. Download binary @@ -165,6 +165,7 @@ trdsql [options] SQL * `-ijson` JSON format for input. * `-iltsv` LTSV format for input. * `-itbln` TBLN format for input. +* `-iwidth` width specification format for input. #### 3.2.1. Input options diff --git a/cmd/cmd.go b/cmd/cmd.go index ffb7958..5d362d7 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -123,7 +123,7 @@ func (cli Cli) Run(args []string) int { flags.BoolVar(&inFlag.LTSV, "iltsv", false, "LTSV format for input.") flags.BoolVar(&inFlag.JSON, "ijson", false, "JSON format for input.") flags.BoolVar(&inFlag.TBLN, "itbln", false, "TBLN format for input.") - flags.BoolVar(&inFlag.GW, "igw", false, "width specification format for input.") + flags.BoolVar(&inFlag.WIDTH, "iwidth", false, "width specification format for input.") flags.StringVar(&outFile, "out", "", "output file name.") flags.BoolVar(&outWithoutGuess, "out-without-guess", false, "output without guessing (when using -out).") @@ -474,11 +474,11 @@ func quotedArg(arg string) string { // inputFlag represents the format of the input. type inputFlag struct { - CSV bool - LTSV bool - JSON bool - TBLN bool - GW bool + CSV bool + LTSV bool + JSON bool + TBLN bool + WIDTH bool } // inputFormat returns format from flag. @@ -492,8 +492,8 @@ func inputFormat(i inputFlag) trdsql.Format { return trdsql.JSON case i.TBLN: return trdsql.TBLN - case i.GW: - return trdsql.GW + case i.WIDTH: + return trdsql.WIDTH default: return trdsql.GUESS } @@ -501,7 +501,7 @@ func inputFormat(i inputFlag) trdsql.Format { func isInFormat(name string) bool { switch name { - case "ig", "icsv", "iltsv", "ijson", "itbln", "igw": + case "ig", "icsv", "iltsv", "ijson", "itbln", "iwidth": return true } return false diff --git a/importer.go b/importer.go index 18a02c2..0521a7d 100644 --- a/importer.go +++ b/importer.go @@ -317,8 +317,8 @@ func guessFormat(fileName string) Format { return JSON case "TBLN": return TBLN - case "GW": - return GW + case "WIDTH": + return WIDTH } fileName = fileName[:len(fileName)-len(dotExt)] } diff --git a/input_gw_test.go b/input_gw_test.go index d75d5e6..e5d5fad 100644 --- a/input_gw_test.go +++ b/input_gw_test.go @@ -55,10 +55,10 @@ func TestNewGWReader(t *testing.T) { return } if !reflect.DeepEqual(got.names, tt.want.names) { - t.Errorf("NewLTSVReader().names = %v, want %v", got.names, tt.want.names) + t.Errorf("NewGWVReader().names = %v, want %v", got.names, tt.want.names) } if !reflect.DeepEqual(got.types, tt.want.types) { - t.Errorf("NewLTSVReader().types = %v, want %v", got.types, tt.want.types) + t.Errorf("NewGWReader().types = %v, want %v", got.types, tt.want.types) } }) } diff --git a/reader.go b/reader.go index 0bd41ff..080ebc4 100644 --- a/reader.go +++ b/reader.go @@ -172,7 +172,7 @@ func NewReader(reader io.Reader, readOpts *ReadOpts) (Reader, error) { return NewJSONReader(reader, readOpts) case TBLN: return NewTBLNReader(reader, readOpts) - case GW: + case WIDTH: return NewGWReader(reader, readOpts) default: return nil, ErrUnknownFormat diff --git a/trdsql.go b/trdsql.go index f1a1d41..c801c55 100644 --- a/trdsql.go +++ b/trdsql.go @@ -64,7 +64,7 @@ const ( // import // Format using guesswidth library. - GW + WIDTH // export // Output as it is. @@ -108,8 +108,8 @@ func (f Format) String() string { return "JSON" case TBLN: return "TBLN" - case GW: - return "GW" + case WIDTH: + return "WIDTH" case RAW: return "RAW" case MD: