Remove merge package, move Merge to input
This commit is contained in:
@@ -115,7 +115,6 @@ declpac/
|
|||||||
│ └── main.go # Entry point
|
│ └── main.go # Entry point
|
||||||
├── pkg/
|
├── pkg/
|
||||||
│ ├── input/ # State file/stdin reading
|
│ ├── input/ # State file/stdin reading
|
||||||
│ ├── merge/ # Package merging
|
|
||||||
│ ├── fetch/ # Package resolution
|
│ ├── fetch/ # Package resolution
|
||||||
│ │ ├── aur/ # AUR support
|
│ │ ├── aur/ # AUR support
|
||||||
│ │ └── alpm/ # ALPM support
|
│ │ └── alpm/ # ALPM support
|
||||||
|
|||||||
+1
-2
@@ -10,7 +10,6 @@ import (
|
|||||||
|
|
||||||
"github.com/Riyyi/declpac/pkg/input"
|
"github.com/Riyyi/declpac/pkg/input"
|
||||||
"github.com/Riyyi/declpac/pkg/log"
|
"github.com/Riyyi/declpac/pkg/log"
|
||||||
"github.com/Riyyi/declpac/pkg/merge"
|
|
||||||
"github.com/Riyyi/declpac/pkg/output"
|
"github.com/Riyyi/declpac/pkg/output"
|
||||||
"github.com/Riyyi/declpac/pkg/pacman"
|
"github.com/Riyyi/declpac/pkg/pacman"
|
||||||
"github.com/Riyyi/declpac/pkg/pacman/read"
|
"github.com/Riyyi/declpac/pkg/pacman/read"
|
||||||
@@ -75,7 +74,7 @@ func run(cfg *Config) error {
|
|||||||
}
|
}
|
||||||
log.Debug("run: packages read (%.2fs)", time.Since(start).Seconds())
|
log.Debug("run: packages read (%.2fs)", time.Since(start).Seconds())
|
||||||
|
|
||||||
merged, err := merge.Merge(packages)
|
merged, err := input.Merge(packages)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -2,11 +2,25 @@ package input
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var ErrEmptyList = errors.New("package list is empty")
|
||||||
|
|
||||||
|
func Merge(packages map[string]bool) ([]string, error) {
|
||||||
|
result := make([]string, 0, len(packages))
|
||||||
|
for name := range packages {
|
||||||
|
result = append(result, name)
|
||||||
|
}
|
||||||
|
if len(result) == 0 {
|
||||||
|
return nil, ErrEmptyList
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
func ReadPackages(stateFiles []string) (map[string]bool, error) {
|
func ReadPackages(stateFiles []string) (map[string]bool, error) {
|
||||||
packages := make(map[string]bool)
|
packages := make(map[string]bool)
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
package merge
|
|
||||||
|
|
||||||
import "errors"
|
|
||||||
|
|
||||||
var ErrEmptyList = errors.New("package list is empty")
|
|
||||||
|
|
||||||
func Merge(packages map[string]bool) ([]string, error) {
|
|
||||||
result := make([]string, 0, len(packages))
|
|
||||||
for name := range packages {
|
|
||||||
result = append(result, name)
|
|
||||||
}
|
|
||||||
if len(result) == 0 {
|
|
||||||
return nil, ErrEmptyList
|
|
||||||
}
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user