✨ Add ic-merge command
Still needs some work, like saving to a new file, but works well so far.
This commit is contained in:
parent
7aae44048a
commit
8a3da4c5fe
8 changed files with 499 additions and 0 deletions
25
infinitecraft/new.go
Normal file
25
infinitecraft/new.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package infinitecraft
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func NewMerger(args []string) (*Merger, error) {
|
||||
m := Merger{}
|
||||
var err error
|
||||
if len(args) < 2 {
|
||||
//nolint:err113 // Don't care
|
||||
return nil, fmt.Errorf("expected at lease 2 arguments. Got %d", len(args))
|
||||
}
|
||||
fs := make([]*os.File, len(args))
|
||||
for idx, pth := range args {
|
||||
fs[idx], err = os.Open(pth)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
m.files = fs
|
||||
|
||||
return &m, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue