Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the commands to importable "impl" package #49

Merged
merged 1 commit into from
Sep 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/siva/list.go → cmd/siva/impl/list.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package impl

import (
"fmt"
Expand Down
4 changes: 2 additions & 2 deletions cmd/siva/list_test.go → cmd/siva/impl/list_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package impl

import (
"bytes"
Expand All @@ -13,7 +13,7 @@ var _ = Suite(&ListSuite{})

func (s *ListSuite) TestBasic(c *C) {
cmd := &CmdList{}
cmd.Args.File = "../../fixtures/perms.siva"
cmd.Args.File = "../../../fixtures/perms.siva"

output := captureOutput(func() {
err := cmd.Execute(nil)
Expand Down
2 changes: 1 addition & 1 deletion cmd/siva/pack.go → cmd/siva/impl/pack.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package impl

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion cmd/siva/pack_test.go → cmd/siva/impl/pack_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package impl

import (
"io/ioutil"
Expand Down
4 changes: 2 additions & 2 deletions cmd/siva/siva.go → cmd/siva/impl/siva.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package impl

import (
"fmt"
Expand All @@ -9,7 +9,7 @@ import (
"github.com/jessevdk/go-flags"
)

func main() {
func Main() {
parser := flags.NewNamedParser("siva", flags.Default)
parser.AddCommand("pack", "Create a new archive containing the specified items.", "", &CmdPack{})
parser.AddCommand("unpack", "Extract to disk from the archive.", "", &CmdUnpack{})
Expand Down
2 changes: 1 addition & 1 deletion cmd/siva/unpack.go → cmd/siva/impl/unpack.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package impl

import (
"fmt"
Expand Down
12 changes: 6 additions & 6 deletions cmd/siva/unpack_test.go → cmd/siva/impl/unpack_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package impl

import (
"io/ioutil"
Expand Down Expand Up @@ -29,7 +29,7 @@ func (s *UnpackSuite) TearDownTest(c *C) {
func (s *UnpackSuite) TestBasic(c *C) {
cmd := &CmdUnpack{}
cmd.Output.Path = filepath.Join(s.folder, "files")
cmd.Args.File = filepath.Join("..", "..", "fixtures", "perms.siva")
cmd.Args.File = filepath.Join("..", "..", "..", "fixtures", "perms.siva")
cmd.Overwrite = true

err := cmd.Execute(nil)
Expand Down Expand Up @@ -57,7 +57,7 @@ func (s *UnpackSuite) TestBasic(c *C) {
func (s *UnpackSuite) TestIgnorePerms(c *C) {
cmd := &CmdUnpack{}
cmd.Output.Path = filepath.Join(s.folder, "files")
cmd.Args.File = filepath.Join("..", "..", "fixtures", "perms.siva")
cmd.Args.File = filepath.Join("..", "..", "..", "fixtures", "perms.siva")
cmd.IgnorePerms = true

err := cmd.Execute(nil)
Expand All @@ -75,7 +75,7 @@ func (s *UnpackSuite) TestIgnorePerms(c *C) {
func (s *UnpackSuite) TestMatch(c *C) {
cmd := &CmdUnpack{}
cmd.Output.Path = filepath.Join(s.folder, "files")
cmd.Args.File = filepath.Join("..", "..", "fixtures", "basic.siva")
cmd.Args.File = filepath.Join("..", "..", "..", "fixtures", "basic.siva")
cmd.Match = "gopher(.*)"

err := cmd.Execute(nil)
Expand All @@ -90,7 +90,7 @@ func (s *UnpackSuite) TestMatch(c *C) {
func (s *UnpackSuite) TestOverwrite(c *C) {
cmd := &CmdUnpack{}
cmd.Output.Path = filepath.Join(s.folder, "files")
cmd.Args.File = filepath.Join("..", "..", "fixtures", "duplicate.siva")
cmd.Args.File = filepath.Join("..", "..", "..", "fixtures", "duplicate.siva")
cmd.Overwrite = true

err := cmd.Execute(nil)
Expand All @@ -104,7 +104,7 @@ func (s *UnpackSuite) TestOverwrite(c *C) {
func (s *UnpackSuite) TestZipSlip(c *C) {
cmd := &CmdUnpack{}
cmd.Output.Path = filepath.Join(s.folder, "files/inside")
cmd.Args.File = filepath.Join("..", "..", "fixtures", "zipslip.siva")
cmd.Args.File = filepath.Join("..", "..", "..", "fixtures", "zipslip.siva")

err := cmd.Execute(nil)
c.Assert(err, NotNil)
Expand Down
2 changes: 1 addition & 1 deletion cmd/siva/unpack_unix.go → cmd/siva/impl/unpack_unix.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// +build !windows

package main
package impl

const defaultPerms = 0755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// +build windows

package main
package impl

const defaultPerms = 0666
2 changes: 1 addition & 1 deletion cmd/siva/version.go → cmd/siva/impl/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package impl

import (
"fmt"
Expand Down
7 changes: 7 additions & 0 deletions cmd/siva/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "gopkg.in/src-d/go-siva.v1/cmd/siva/impl"

func main() {
impl.Main()
}