Skip to content

Commit 827c9ef

Browse files
authored
1) EDI doc 2) add ignore_crlf to edi schema 3) add default to edi schema 4) make edi err msg more useful 5) fix cli.sh (#129)
1) EDI doc 2) add `ignore_crlf` to edi schema 3) add `default` to edi schema 4) make edi err msg more useful 5) fix cli.sh
1 parent 6fc8075 commit 827c9ef

20 files changed

+4996
-28
lines changed

cli.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/bash
22
CUR_DIR=$(pwd)
3-
SCRIPT_DIR=$(dirname "$0")
4-
cd $SCRIPT_DIR && \
3+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)"
4+
cd "$SCRIPT_DIR" && \
55
go build \
6-
-o $CUR_DIR/op \
6+
-o "$CUR_DIR/op" \
77
-ldflags "-X main.gitCommit=$(git rev-parse HEAD) -X main.buildEpochSec=$(date +%s)" \
8-
$SCRIPT_DIR/cli/op.go
9-
cd $CUR_DIR && ./op "$@"
8+
"$SCRIPT_DIR/cli/op.go"
9+
cd "$CUR_DIR" && ./op "$@"

cli/cmd/transformCmd.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ var (
2222
Short: "Transforms input to desired output based on a schema.",
2323
Args: cobra.NoArgs,
2424
RunE: func(cmd *cobra.Command, _ []string) error {
25-
return doTransform()
25+
if err := doTransform(); err != nil {
26+
fmt.Println() // to sure cobra cli always write out "Error: ..." on a new line.
27+
return err
28+
}
29+
return nil
2630
},
2731
}
2832
schema string

doc/edi_in_depth.md

Lines changed: 697 additions & 0 deletions
Large diffs are not rendered by default.

doc/resources/edi_comp_delim.png

52.3 KB
Loading

doc/resources/edi_seg_structure.png

118 KB
Loading
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"Records": null,
3-
"FinalErr": "input 'test' between character [1,6]: missing segment name"
3+
"FinalErr": "input 'test' at segment no.1 (char[1,6]): missing segment name"
44
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"Records": null,
3-
"FinalErr": "input 'test' between character [1,7]: unable to find element 'e2' on segment ''"
3+
"FinalErr": "input 'test' at segment no.1 (char[1,7]): unable to find element 'e2' on segment ''"
44
}

extensions/omniv21/fileformat/edi/.snapshots/TestRead-seg_min_not_satisfied_before_EOF,_failure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"Records": [
33
"{'e1':'0','e2':'1','e3':'2'}"
44
],
5-
"FinalErr": "input 'test' between character [11,11]: segment 'IEA' needs min occur 1, but only got 0"
5+
"FinalErr": "input 'test' at segment no.3 (char[11,11]): segment 'IEA' needs min occur 1, but only got 0"
66
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"Records": null,
3-
"FinalErr": "input 'test' between character [7,7]: segment 'ISA' needs min occur 1, but only got 0"
3+
"FinalErr": "input 'test' at segment no.1 (char[7,7]): segment 'ISA' needs min occur 1, but only got 0"
44
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"Records": [
33
"{'e1':'0','e2':'1','e3':'2'}",
4-
"{'e1':'3','e2':'','e3':''}"
4+
"{'e1':'3','e2':'','e3':'x'}"
55
],
66
"FinalErr": "EOF"
77
}

0 commit comments

Comments
 (0)