Skip to content

Commit

Permalink
Changed option name from gw to width
Browse files Browse the repository at this point in the history
  • Loading branch information
noborus committed Mar 18, 2023
1 parent 65e0f3d commit d645241
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ $ make install

#### 1.1.1. <a name='requirements'></a>Requirements

go 1.17 or higher.
go 1.18 or higher.

### 1.2. <a name='download-binary'></a>Download binary

Expand Down Expand Up @@ -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. <a name='input-options'></a>Input options

Expand Down
18 changes: 9 additions & 9 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).")
Expand Down Expand Up @@ -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.
Expand All @@ -492,16 +492,16 @@ 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
}
}

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
Expand Down
4 changes: 2 additions & 2 deletions importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
}
Expand Down
4 changes: 2 additions & 2 deletions input_gw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions trdsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const (

// import
// Format using guesswidth library.
GW
WIDTH

// export
// Output as it is.
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit d645241

Please sign in to comment.