change the pointer command's switches

This commit is contained in:
Rick Olson 2015-04-22 13:17:53 -06:00
parent c6b722db63
commit bd1b1ed793
3 changed files with 16 additions and 16 deletions

@ -13,7 +13,7 @@ import (
)
var (
pointerBuild string
pointerFile string
pointerCompare string
pointerCmd = &cobra.Command{
Use: "pointer",
@ -32,9 +32,9 @@ func pointerCommand(cmd *cobra.Command, args []string) {
comparing = true
}
if len(pointerBuild) > 0 {
if len(pointerFile) > 0 {
something = true
buildFile, err := os.Open(pointerBuild)
buildFile, err := os.Open(pointerFile)
if err != nil {
Error(err.Error())
os.Exit(1)
@ -50,7 +50,7 @@ func pointerCommand(cmd *cobra.Command, args []string) {
}
ptr := pointer.NewPointer(hex.EncodeToString(oidHash.Sum(nil)), size)
fmt.Printf("Git LFS pointer for %s\n\n", pointerBuild)
fmt.Printf("Git LFS pointer for %s\n\n", pointerFile)
buf := &bytes.Buffer{}
pointer.Encode(io.MultiWriter(os.Stdout, buf), ptr)
@ -114,7 +114,7 @@ func gitHashObject(by []byte) string {
func init() {
flags := pointerCmd.Flags()
flags.StringVarP(&pointerBuild, "build", "b", "", "Path to a local file to generate the pointer from.")
flags.StringVarP(&pointerCompare, "compare", "c", "", "Path to a local file containing a pointer built by another Git LFS implementation.")
flags.StringVarP(&pointerFile, "file", "f", "", "Path to a local file to generate the pointer from.")
flags.StringVarP(&pointerCompare, "pointer", "p", "", "Path to a local file containing a pointer built by another Git LFS implementation.")
RootCmd.AddCommand(pointerCmd)
}

@ -16,7 +16,7 @@ func TestPointerWithBuildAndCompareMismatch(t *testing.T) {
"oid sha256:6c17f2007cbe934aee6e309b28b2dba3c119c5dff2ef813ed124699efe319868\n" +
"size 123"
cmd := repo.Command("pointer", "--build=some/file", "--compare=some/pointer")
cmd := repo.Command("pointer", "--file=some/file", "--pointer=some/pointer")
cmd.Unsuccessful = true
cmd.Before(func() {
path := filepath.Join(repo.Path, "some")
@ -44,7 +44,7 @@ func TestPointerWithBuildAndCompare(t *testing.T) {
"oid sha256:6c17f2007cbe934aee6e309b28b2dba3c119c5dff2ef813ed124699efe319868\n" +
"size 7"
cmd := repo.Command("pointer", "--build=some/file", "--compare=some/pointer")
cmd := repo.Command("pointer", "--file=some/file", "--pointer=some/pointer")
cmd.Before(func() {
path := filepath.Join(repo.Path, "some")
assert.Equal(t, nil, os.MkdirAll(path, 0755))
@ -68,7 +68,7 @@ func TestPointerWithCompare(t *testing.T) {
"oid sha256:6c17f2007cbe934aee6e309b28b2dba3c119c5dff2ef813ed124699efe319868\n" +
"size 7"
cmd := repo.Command("pointer", "--compare=some/pointer")
cmd := repo.Command("pointer", "--pointer=some/pointer")
cmd.Before(func() {
path := filepath.Join(repo.Path, "some")
filename := filepath.Join(path, "pointer")
@ -83,7 +83,7 @@ func TestPointerWithInvalidCompare(t *testing.T) {
repo := NewRepository(t, "empty")
defer repo.Test()
cmd := repo.Command("pointer", "--compare=some/pointer")
cmd := repo.Command("pointer", "--pointer=some/pointer")
cmd.Output = "open some/pointer: no such file or directory"
cmd.Unsuccessful = true
}
@ -92,7 +92,7 @@ func TestPointerWithNonPointerCompare(t *testing.T) {
repo := NewRepository(t, "empty")
defer repo.Test()
cmd := repo.Command("pointer", "--compare=some/pointer")
cmd := repo.Command("pointer", "--pointer=some/pointer")
cmd.Before(func() {
path := filepath.Join(repo.Path, "some")
assert.Equal(t, nil, os.MkdirAll(path, 0755))
@ -107,7 +107,7 @@ func TestPointerWithBuild(t *testing.T) {
repo := NewRepository(t, "empty")
defer repo.Test()
cmd := repo.Command("pointer", "--build=some/file")
cmd := repo.Command("pointer", "--file=some/file")
cmd.Before(func() {
path := filepath.Join(repo.Path, "some")
filename := filepath.Join(path, "file")
@ -125,7 +125,7 @@ func TestPointerWithInvalidBuild(t *testing.T) {
repo := NewRepository(t, "empty")
defer repo.Test()
cmd := repo.Command("pointer", "--build=some/file")
cmd := repo.Command("pointer", "--file=some/file")
cmd.Output = "open some/file: no such file or directory"
cmd.Unsuccessful = true
}

@ -58,7 +58,7 @@ don't know or care about.
* Run the `pointer` command to generate a pointer file for the given local
file:
$ git lfs pointer --build=path/to/file
$ git lfs pointer --file=path/to/file
Git LFS pointer for path/to/file:
version https://git-lfs.github.com/spec/v1
@ -70,7 +70,7 @@ a pointer built by another tool.
* Write the other implementation's pointer to "other/pointer/file":
$ git lfs pointer --build=path/to/file --compare=other/pointer/file
$ git lfs pointer --file=path/to/file --pointer=other/pointer/file
Git LFS pointer for path/to/file:
version https://git-lfs.github.com/spec/v1
@ -90,7 +90,7 @@ a pointer built by another tool.
* It can also read STDIN to get the other implementation's pointer:
$ cat other/pointer/file | git lfs pointer --build=path/to/file --stdin
$ cat other/pointer/file | git lfs pointer --file=path/to/file --stdin
Git LFS pointer for path/to/file:
version https://git-lfs.github.com/spec/v1