Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
cmd: Minor tweaks to output
Browse files Browse the repository at this point in the history
  • Loading branch information
mholt committed Dec 4, 2018
1 parent 4846eaa commit d572b2e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
12 changes: 3 additions & 9 deletions archiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,21 +192,15 @@ func Archive(sources []string, destination string) error {
}

// Unarchive unarchives the given archive file into the destination folder.
// The archive format is selected implicitly based on the file's header.
// The archive format is selected implicitly.
func Unarchive(source, destination string) error {
f, err := os.Open(source)
uaIface, err := ByExtension(source)
if err != nil {
return err
}
uaIface, err := ByHeader(f)
if err != nil {
f.Close()
return err
}
f.Close()
u, ok := uaIface.(Unarchiver)
if !ok {
return fmt.Errorf("format specified by destination filename is not an archive format: %s (%T)", destination, uaIface)
return fmt.Errorf("format specified by source filename is not an archive format: %s (%T)", source, uaIface)
}
return u.Unarchive(source, destination)
}
Expand Down
8 changes: 3 additions & 5 deletions cmd/arc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ func main() {
fatal(err)
}

fmt.Printf("VALUE: %#v\n", iface)

// run the desired command
switch subcommand {
case "archive":
Expand All @@ -63,11 +61,11 @@ func main() {
err = a.Archive(flag.Args()[2:], flag.Arg(1))

case "unarchive":
a, ok := iface.(archiver.Unarchiver)
u, ok := iface.(archiver.Unarchiver)
if !ok {
fatalf("the unarchive command does not support the %s format", iface)
}
err = a.Unarchive(flag.Arg(1), flag.Arg(2))
err = u.Unarchive(flag.Arg(1), flag.Arg(2))

case "extract":
e, ok := iface.(archiver.Extractor)
Expand Down Expand Up @@ -124,7 +122,7 @@ func main() {
return nil
})

fmt.Printf("total %d", count)
fmt.Printf("total %d\n", count)

case "compress":
c, ok := iface.(archiver.Compressor)
Expand Down

0 comments on commit d572b2e

Please sign in to comment.