2021-05-09 18:06:08 +03:00
|
|
|
package mergelbl
|
|
|
|
|
|
|
|
import(
|
|
|
|
"os"
|
|
|
|
"fmt"
|
|
|
|
"bufio"
|
|
|
|
"log"
|
2024-05-15 21:07:35 +03:00
|
|
|
"surdeus.su/core/cli/mtool"
|
2021-05-09 18:06:08 +03:00
|
|
|
)
|
|
|
|
|
2023-03-24 16:54:51 +03:00
|
|
|
func Run(flagSet *mtool.Flags) {
|
2021-05-09 18:06:08 +03:00
|
|
|
var(
|
|
|
|
e error
|
|
|
|
buf string
|
|
|
|
)
|
|
|
|
rsep := '\n'
|
|
|
|
wsep := "\n"
|
|
|
|
//del := ""
|
2023-03-24 16:54:51 +03:00
|
|
|
flagSet.Parse()
|
|
|
|
args := flagSet.Args()
|
2021-05-09 18:06:08 +03:00
|
|
|
|
|
|
|
files := make([]*os.File, len(args))
|
|
|
|
for i, v := range args {
|
|
|
|
files[i], e = os.Open(v)
|
|
|
|
if e!=nil {
|
|
|
|
log.Fatal(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rds := make([]*bufio.Reader, len(files))
|
|
|
|
for i, v := range files {
|
|
|
|
rds[i] = bufio.NewReader(v)
|
|
|
|
}
|
|
|
|
|
|
|
|
for{
|
|
|
|
s := ""
|
|
|
|
for _, r := range rds{
|
|
|
|
buf, e = r.ReadString(byte(rsep))
|
|
|
|
if e!=nil {
|
2022-06-16 09:31:23 +03:00
|
|
|
os.Exit(1)
|
2021-05-09 18:06:08 +03:00
|
|
|
}
|
|
|
|
s += buf[:len(buf)-1]
|
|
|
|
}
|
|
|
|
fmt.Printf("%s%s", s, wsep)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|