Skip to content

Commit f11647c

Browse files
committed
cmd/achcli: initial structure
1 parent efc9509 commit f11647c

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed

cmd/achcli/fix/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package fix
2+
3+
type Config struct {
4+
UpdateEED string
5+
}

cmd/achcli/fix/fix.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package fix
2+
3+
func Perform(paths string, conf Config) (string, error) {
4+
// file, err := ach.ReadFile(
5+
6+
// TODO(adam): pass validateOpts to each reader
7+
// validateOpts := readValidationOpts(*flagValidateOpts)
8+
9+
// func ReadJSONFile(path string) (*File, error)
10+
// func ReadFile(path string) (*File, error)
11+
12+
return paths +".fix", nil
13+
}
14+
15+
// TODO(adam): process file batch by batch
16+
// TODO(adam): fix funcs take a file header, batch, entry, etc
17+
18+
// TODO(adam): updateEED()
19+
20+
// TODO(adam): write output to disk

cmd/achcli/fix/fix_eed.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package fix
2+
3+
func updateEED() error {
4+
return nil
5+
}

cmd/achcli/main.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"strings"
1313

1414
"github.com/moov-io/ach"
15+
"github.com/moov-io/ach/cmd/achcli/fix"
1516
)
1617

1718
var (
@@ -33,6 +34,10 @@ var (
3334

3435
flagSkipValidation = flag.Bool("skip-validation", false, "Skip all validation checks")
3536
flagValidateOpts = flag.String("validate", "", "Path to config file in json format to enable validation opts")
37+
38+
// Fix commands
39+
flagFix = flag.Bool("fix", false, "Trigger fix tasks")
40+
flagUpdateEED = flag.String("update-eed", "", "Set the EffectiveEntryDate to a new value")
3641
)
3742

3843
func main() {
@@ -78,6 +83,21 @@ func main() {
7883
os.Exit(1)
7984
}
8085

86+
case *flagFix:
87+
if len(args) != 1 {
88+
fmt.Printf("ERROR: unexpected %d arguments: %#v\n", len(args), args)
89+
os.Exit(1)
90+
}
91+
conf := fix.Config{
92+
UpdateEED: *flagUpdateEED,
93+
}
94+
newpath, err := fix.Perform(args[0], conf);
95+
if err != nil {
96+
fmt.Printf("ERROR: %v\n", err)
97+
os.Exit(1)
98+
}
99+
fmt.Printf("New file: %s\n", newpath)
100+
81101
case *flagReformat != "" && len(args) == 1:
82102
if err := reformat(*flagReformat, args[0], validateOpts); err != nil {
83103
fmt.Printf("ERROR: %v\n", err)

0 commit comments

Comments
 (0)