move noms/samples/go/flags -> noms/go/spec (#1799)

This commit is contained in:
Aaron Boodman
2016-06-12 15:42:50 -07:00
committed by GitHub
parent 3633a8433d
commit fcf772dccd
17 changed files with 65 additions and 65 deletions

View File

@@ -11,8 +11,8 @@ import (
"os"
"github.com/attic-labs/noms/cmd/noms-diff/diff"
"github.com/attic-labs/noms/go/spec"
"github.com/attic-labs/noms/go/util/outputpager"
"github.com/attic-labs/noms/samples/go/flags"
"github.com/attic-labs/noms/samples/go/util"
)
@@ -43,9 +43,9 @@ func main() {
util.CheckError(errors.New("expected exactly two arguments"))
}
spec1, err := flags.ParsePathSpec(flag.Arg(0))
spec1, err := spec.ParsePathSpec(flag.Arg(0))
util.CheckError(err)
spec2, err := flags.ParsePathSpec(flag.Arg(1))
spec2, err := spec.ParsePathSpec(flag.Arg(1))
util.CheckError(err)
db1, value1, err := spec1.Value()

View File

@@ -9,8 +9,8 @@ import (
"fmt"
"os"
"github.com/attic-labs/noms/go/spec"
"github.com/attic-labs/noms/go/types"
"github.com/attic-labs/noms/samples/go/flags"
"github.com/attic-labs/noms/samples/go/util"
)
@@ -27,7 +27,7 @@ func main() {
flag.Parse()
if *toDelete != "" {
setSpec, err := flags.ParseDatasetSpec(*toDelete)
setSpec, err := spec.ParseDatasetSpec(*toDelete)
util.CheckError(err)
set, err := setSpec.Dataset()
@@ -49,7 +49,7 @@ func main() {
return
}
storeSpec, err := flags.ParseDatabaseSpec(flag.Arg(0))
storeSpec, err := spec.ParseDatabaseSpec(flag.Arg(0))
util.CheckError(err)
store, err := storeSpec.Database()

View File

@@ -15,9 +15,9 @@ import (
"github.com/attic-labs/noms/cmd/noms-diff/diff"
"github.com/attic-labs/noms/go/datas"
"github.com/attic-labs/noms/go/spec"
"github.com/attic-labs/noms/go/types"
"github.com/attic-labs/noms/go/util/outputpager"
"github.com/attic-labs/noms/samples/go/flags"
"github.com/attic-labs/noms/samples/go/util"
"github.com/mgutz/ansi"
)
@@ -56,7 +56,7 @@ func main() {
useColor = shouldUseColor()
spec, err := flags.ParsePathSpec(flag.Arg(0))
spec, err := spec.ParsePathSpec(flag.Arg(0))
util.CheckError(err)
database, value, err := spec.Value()
if err != nil {

View File

@@ -9,8 +9,8 @@ import (
"testing"
"github.com/attic-labs/noms/go/dataset"
"github.com/attic-labs/noms/go/spec"
"github.com/attic-labs/noms/go/types"
"github.com/attic-labs/noms/samples/go/flags"
"github.com/attic-labs/noms/samples/go/test_util"
"github.com/attic-labs/noms/samples/go/util"
"github.com/attic-labs/testify/assert"
@@ -39,8 +39,8 @@ type nomsShowTestSuite struct {
test_util.ClientTestSuite
}
func testCommitInResults(s *nomsShowTestSuite, spec string, i int) {
sp, err := flags.ParseDatasetSpec(spec)
func testCommitInResults(s *nomsShowTestSuite, str string, i int) {
sp, err := spec.ParseDatasetSpec(str)
s.NoError(err)
ds, err := sp.Dataset()
s.NoError(err)
@@ -48,22 +48,22 @@ func testCommitInResults(s *nomsShowTestSuite, spec string, i int) {
s.NoError(err)
commit := ds.Head()
ds.Database().Close()
s.Contains(s.Run(main, []string{spec}), commit.Hash().String())
s.Contains(s.Run(main, []string{str}), commit.Hash().String())
}
func (s *nomsShowTestSuite) TestNomsLog() {
datasetName := "dsTest"
spec := test_util.CreateValueSpecString("ldb", s.LdbDir, datasetName)
sp, err := flags.ParseDatasetSpec(spec)
str := test_util.CreateValueSpecString("ldb", s.LdbDir, datasetName)
sp, err := spec.ParseDatasetSpec(str)
s.NoError(err)
ds, err := sp.Dataset()
s.NoError(err)
ds.Database().Close()
s.Panics(func() { s.Run(main, []string{spec}) })
s.Panics(func() { s.Run(main, []string{str}) })
testCommitInResults(s, spec, 1)
testCommitInResults(s, spec, 2)
testCommitInResults(s, str, 1)
testCommitInResults(s, str, 2)
}
func addCommit(ds dataset.Dataset, v string) (dataset.Dataset, error) {
@@ -83,9 +83,9 @@ func mergeDatasets(ds1, ds2 dataset.Dataset, v string) (dataset.Dataset, error)
}
func (s *nomsShowTestSuite) TestNArg() {
spec := test_util.CreateDatabaseSpecString("ldb", s.LdbDir)
str := test_util.CreateDatabaseSpecString("ldb", s.LdbDir)
dsName := "nArgTest"
dbSpec, err := flags.ParseDatabaseSpec(spec)
dbSpec, err := spec.ParseDatabaseSpec(str)
s.NoError(err)
db, err := dbSpec.Database()
s.NoError(err)
@@ -119,8 +119,8 @@ func (s *nomsShowTestSuite) TestNArg() {
}
func (s *nomsShowTestSuite) TestNomsGraph1() {
spec := test_util.CreateDatabaseSpecString("ldb", s.LdbDir)
dbSpec, err := flags.ParseDatabaseSpec(spec)
str := test_util.CreateDatabaseSpecString("ldb", s.LdbDir)
dbSpec, err := spec.ParseDatabaseSpec(str)
s.NoError(err)
db, err := dbSpec.Database()
s.NoError(err)
@@ -172,8 +172,8 @@ func (s *nomsShowTestSuite) TestNomsGraph1() {
}
func (s *nomsShowTestSuite) TestNomsGraph2() {
spec := test_util.CreateDatabaseSpecString("ldb", s.LdbDir)
dbSpec, err := flags.ParseDatabaseSpec(spec)
str := test_util.CreateDatabaseSpecString("ldb", s.LdbDir)
dbSpec, err := spec.ParseDatabaseSpec(str)
s.NoError(err)
db, err := dbSpec.Database()
s.NoError(err)
@@ -203,8 +203,8 @@ func (s *nomsShowTestSuite) TestNomsGraph2() {
}
func (s *nomsShowTestSuite) TestNomsGraph3() {
spec := test_util.CreateDatabaseSpecString("ldb", s.LdbDir)
dbSpec, err := flags.ParseDatabaseSpec(spec)
str := test_util.CreateDatabaseSpecString("ldb", s.LdbDir)
dbSpec, err := spec.ParseDatabaseSpec(str)
s.NoError(err)
db, err := dbSpec.Database()
s.NoError(err)
@@ -252,8 +252,8 @@ func (s *nomsShowTestSuite) TestTruncation() {
return types.NewList(nv...)
}
spec := test_util.CreateDatabaseSpecString("ldb", s.LdbDir)
dbSpec, err := flags.ParseDatabaseSpec(spec)
str := test_util.CreateDatabaseSpecString("ldb", s.LdbDir)
dbSpec, err := spec.ParseDatabaseSpec(str)
s.NoError(err)
db, err := dbSpec.Database()
s.NoError(err)

View File

@@ -14,8 +14,8 @@ import (
"github.com/attic-labs/noms/go/d"
"github.com/attic-labs/noms/go/datas"
"github.com/attic-labs/noms/go/spec"
"github.com/attic-labs/noms/go/util/profile"
"github.com/attic-labs/noms/samples/go/flags"
"github.com/attic-labs/noms/samples/go/util"
)
@@ -31,7 +31,7 @@ func main() {
fmt.Fprintf(os.Stderr, "\nFor detailed information on spelling databases, see: at https://github.com/attic-labs/noms/blob/master/doc/spelling.md.\n\n")
}
flags.RegisterDatabaseFlags()
spec.RegisterDatabaseFlags()
flag.Parse()
if len(flag.Args()) != 1 {
@@ -39,7 +39,7 @@ func main() {
return
}
spec, err := flags.ParseDatabaseSpec(flag.Arg(0))
spec, err := spec.ParseDatabaseSpec(flag.Arg(0))
util.CheckError(err)
if spec.Protocol != "mem" && spec.Protocol != "ldb" {
err := errors.New("Illegal database spec for server, must be 'mem' or 'ldb'")

View File

@@ -10,9 +10,9 @@ import (
"fmt"
"os"
"github.com/attic-labs/noms/go/spec"
"github.com/attic-labs/noms/go/types"
"github.com/attic-labs/noms/go/util/outputpager"
"github.com/attic-labs/noms/samples/go/flags"
"github.com/attic-labs/noms/samples/go/util"
)
@@ -38,7 +38,7 @@ func main() {
util.CheckError(errors.New("expected exactly one argument"))
}
spec, err := flags.ParsePathSpec(flag.Arg(0))
spec, err := spec.ParsePathSpec(flag.Arg(0))
util.CheckError(err)
database, value, err := spec.Value()
util.CheckError(err)

View File

@@ -9,8 +9,8 @@ import (
"github.com/attic-labs/noms/go/d"
"github.com/attic-labs/noms/go/dataset"
"github.com/attic-labs/noms/go/spec"
"github.com/attic-labs/noms/go/types"
"github.com/attic-labs/noms/samples/go/flags"
"github.com/attic-labs/noms/samples/go/test_util"
"github.com/attic-labs/testify/suite"
)
@@ -43,15 +43,15 @@ func writeTestData(ds dataset.Dataset, value types.Value) types.Ref {
func (s *nomsShowTestSuite) TestNomsShow() {
datasetName := "dsTest"
spec := test_util.CreateValueSpecString("ldb", s.LdbDir, datasetName)
sp, err := flags.ParseDatasetSpec(spec)
str := test_util.CreateValueSpecString("ldb", s.LdbDir, datasetName)
sp, err := spec.ParseDatasetSpec(str)
d.Chk.NoError(err)
ds, err := sp.Dataset()
d.Chk.NoError(err)
s1 := types.NewString("test string")
r := writeTestData(ds, s1)
s.Equal(res1, s.Run(main, []string{spec}))
s.Equal(res1, s.Run(main, []string{str}))
spec1 := test_util.CreateValueSpecString("ldb", s.LdbDir, r.TargetHash().String())
s.Equal(res2, s.Run(main, []string{spec1}))
@@ -59,12 +59,12 @@ func (s *nomsShowTestSuite) TestNomsShow() {
ds, err = sp.Dataset()
list := types.NewList(types.NewString("elem1"), types.Number(2), types.NewString("elem3"))
r = writeTestData(ds, list)
s.Equal(res3, s.Run(main, []string{spec}))
s.Equal(res3, s.Run(main, []string{str}))
spec1 = test_util.CreateValueSpecString("ldb", s.LdbDir, r.TargetHash().String())
s.Equal(res4, s.Run(main, []string{spec1}))
ds, err = sp.Dataset()
_ = writeTestData(ds, s1)
s.Equal(res5, s.Run(main, []string{spec}))
s.Equal(res5, s.Run(main, []string{str}))
}

View File

@@ -13,9 +13,9 @@ import (
"runtime"
"github.com/attic-labs/noms/go/d"
"github.com/attic-labs/noms/go/spec"
"github.com/attic-labs/noms/go/types"
"github.com/attic-labs/noms/go/util/profile"
"github.com/attic-labs/noms/samples/go/flags"
"github.com/attic-labs/noms/samples/go/util"
)
@@ -34,20 +34,20 @@ func main() {
fmt.Fprintf(os.Stderr, "\nFor detailed information on spelling objects and datasets, see: at https://github.com/attic-labs/noms/blob/master/doc/spelling.md.\n\n")
}
flags.RegisterDatabaseFlags()
spec.RegisterDatabaseFlags()
flag.Parse()
if flag.NArg() != 2 {
util.CheckError(errors.New("expected a source object and destination dataset"))
}
sourceSpec, err := flags.ParsePathSpec(flag.Arg(0))
sourceSpec, err := spec.ParsePathSpec(flag.Arg(0))
util.CheckError(err)
sourceStore, sourceObj, err := sourceSpec.Value()
util.CheckError(err)
defer sourceStore.Close()
sinkSpec, err := flags.ParseDatasetSpec(flag.Arg(1))
sinkSpec, err := spec.ParseDatasetSpec(flag.Arg(1))
util.CheckError(err)
sinkDataset, err := sinkSpec.Dataset()

View File

@@ -2,7 +2,7 @@
// Licensed under the Apache License, version 2.0:
// http://www.apache.org/licenses/LICENSE-2.0
package flags
package spec
import (
"fmt"

View File

@@ -2,7 +2,7 @@
// Licensed under the Apache License, version 2.0:
// http://www.apache.org/licenses/LICENSE-2.0
package flags
package spec
import (
"fmt"

View File

@@ -12,8 +12,8 @@ import (
"github.com/attic-labs/noms/go/d"
"github.com/attic-labs/noms/go/datas"
"github.com/attic-labs/noms/go/spec"
"github.com/attic-labs/noms/go/types"
"github.com/attic-labs/noms/samples/go/flags"
"github.com/attic-labs/noms/samples/go/util"
)
@@ -23,14 +23,14 @@ func main() {
flag.PrintDefaults()
}
flags.RegisterDatabaseFlags()
spec.RegisterDatabaseFlags()
flag.Parse()
if flag.NArg() != 1 {
util.CheckError(errors.New("expected dataset arg"))
}
spec, err := flags.ParseDatasetSpec(flag.Arg(0))
spec, err := spec.ParseDatasetSpec(flag.Arg(0))
util.CheckError(err)
ds, err := spec.Dataset()
util.CheckError(err)

View File

@@ -13,8 +13,8 @@ import (
"github.com/attic-labs/noms/go/d"
"github.com/attic-labs/noms/go/datas"
"github.com/attic-labs/noms/go/spec"
"github.com/attic-labs/noms/samples/go/csv"
"github.com/attic-labs/noms/samples/go/flags"
"github.com/attic-labs/noms/samples/go/util"
)
@@ -25,7 +25,7 @@ var (
)
func main() {
flags.RegisterDatabaseFlags()
spec.RegisterDatabaseFlags()
cpuCount := runtime.NumCPU()
runtime.GOMAXPROCS(cpuCount)
@@ -40,7 +40,7 @@ func main() {
util.CheckError(errors.New("expected dataset arg"))
}
spec, err := flags.ParseDatasetSpec(flag.Arg(0))
spec, err := spec.ParseDatasetSpec(flag.Arg(0))
util.CheckError(err)
ds, err := spec.Dataset()

View File

@@ -16,12 +16,12 @@ import (
"time"
"github.com/attic-labs/noms/go/d"
"github.com/attic-labs/noms/go/spec"
"github.com/attic-labs/noms/go/types"
"github.com/attic-labs/noms/go/util/profile"
"github.com/attic-labs/noms/go/util/progressreader"
"github.com/attic-labs/noms/go/util/status"
"github.com/attic-labs/noms/samples/go/csv"
"github.com/attic-labs/noms/samples/go/flags"
"github.com/attic-labs/noms/samples/go/util"
humanize "github.com/dustin/go-humanize"
@@ -45,7 +45,7 @@ func main() {
destTypePattern = regexp.MustCompile("^(list|map):(\\d+)$")
)
flags.RegisterDatabaseFlags()
spec.RegisterDatabaseFlags()
cpuCount := runtime.NumCPU()
runtime.GOMAXPROCS(cpuCount)
@@ -105,7 +105,7 @@ func main() {
headers = strings.Split(*header, string(comma))
}
spec, err := flags.ParseDatasetSpec(flag.Arg(0))
spec, err := spec.ParseDatasetSpec(flag.Arg(0))
util.CheckError(err)
ds, err := spec.Dataset()
util.CheckError(err)

View File

@@ -14,7 +14,7 @@ import (
"os"
"github.com/attic-labs/noms/go/d"
"github.com/attic-labs/noms/samples/go/flags"
"github.com/attic-labs/noms/go/spec"
"github.com/attic-labs/noms/samples/go/util"
)
@@ -24,14 +24,14 @@ func main() {
flag.PrintDefaults()
}
flags.RegisterDatabaseFlags()
spec.RegisterDatabaseFlags()
flag.Parse()
if len(flag.Args()) != 2 {
util.CheckError(errors.New("expected url and dataset flags"))
}
spec, err := flags.ParseDatasetSpec(flag.Arg(1))
spec, err := spec.ParseDatasetSpec(flag.Arg(1))
util.CheckError(err)
ds, err := spec.Dataset()
util.CheckError(err)

View File

@@ -5,13 +5,13 @@
package test_util
import (
"fmt"
"fmt"
)
func CreateDatabaseSpecString(protocol, path string) string {
return fmt.Sprintf("%s:%s", protocol, path)
return fmt.Sprintf("%s:%s", protocol, path)
}
func CreateValueSpecString(protocol, path, value string) string {
return fmt.Sprintf("%s:%s::%s", protocol, path, value)
return fmt.Sprintf("%s:%s::%s", protocol, path, value)
}

View File

@@ -16,10 +16,10 @@ import (
"github.com/attic-labs/noms/go/d"
"github.com/attic-labs/noms/go/datas"
"github.com/attic-labs/noms/go/spec"
"github.com/attic-labs/noms/go/types"
"github.com/attic-labs/noms/go/util/progressreader"
"github.com/attic-labs/noms/go/util/status"
"github.com/attic-labs/noms/samples/go/flags"
"github.com/attic-labs/noms/samples/go/util"
human "github.com/dustin/go-humanize"
)
@@ -34,14 +34,14 @@ func main() {
flag.PrintDefaults()
}
flags.RegisterDatabaseFlags()
spec.RegisterDatabaseFlags()
flag.Parse()
if flag.NArg() != 2 {
util.CheckError(errors.New("expected dataset and url arguments"))
}
spec, err := flags.ParseDatasetSpec(flag.Arg(0))
spec, err := spec.ParseDatasetSpec(flag.Arg(0))
if err != nil {
util.CheckError(err)
}

View File

@@ -16,9 +16,9 @@ import (
"sync"
"github.com/attic-labs/noms/go/d"
"github.com/attic-labs/noms/go/spec"
"github.com/attic-labs/noms/go/types"
"github.com/attic-labs/noms/go/util/profile"
"github.com/attic-labs/noms/samples/go/flags"
"github.com/attic-labs/noms/samples/go/util"
"github.com/clbanning/mxj"
)
@@ -51,7 +51,7 @@ func (a refIndexList) Less(i, j int) bool { return a[i].index < a[j].index }
func main() {
err := d.Try(func() {
flags.RegisterDatabaseFlags()
spec.RegisterDatabaseFlags()
flag.Usage = customUsage
flag.Parse()
@@ -59,7 +59,7 @@ func main() {
util.CheckError(errors.New("Expected dataset followed by directory path"))
}
dir := flag.Arg(1)
spec, err := flags.ParseDatasetSpec(flag.Arg(0))
spec, err := spec.ParseDatasetSpec(flag.Arg(0))
util.CheckError(err)
ds, err := spec.Dataset()
util.CheckError(err)