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

Should "drive rename" also rename the local file/directory? #459

Closed
smblott-github opened this issue Nov 5, 2015 · 4 comments · Fixed by #632
Closed

Should "drive rename" also rename the local file/directory? #459

smblott-github opened this issue Nov 5, 2015 · 4 comments · Fixed by #632
Milestone

Comments

@smblott-github
Copy link

$ drive pull foo
$ drive rename foo bar
$ ls
foo

That's pretty weird.

Might it be better to rename the local file/directory too, if present?

A bad use case would be if there's a local file/directory which just happens to have the same name. So perhaps such a feature would have to be optional:

drive rename -rename-local=true foo bar
@odeke-em
Copy link
Owner

odeke-em commented Nov 5, 2015

Yap I agree, the only problem though is that you can't rollback locally and a lot of information has to be compared to make sure local and remote match up. I originally was going to implement it so that it works both ways but hesitated for a couple of reasons one of them being what you mentioned a local clash, not being able to rollback etc. I agree we could have an optional mode. BTW the exact same thing applies for move, delete, copy, new where they work only remotely.

@smblott-github
Copy link
Author

An alternative would be to have a shell wrapper; e.g., here's a quick hack:

#!/usr/bin/zsh

if command $0 $argv && (( 0 < $#argv ))
then
   local cmnd=$argv[1]
   shift
   while (( 0 < $#argv )) && [[ $argv[1] == -* ]]
   do
      shift
   done
   case $cmnd in
      'rename' ) mv -v $argv  ;;
      'move'   ) mv -v $argv  ;;
      'mv'     ) mv -v $argv  ;;

      'delete' ) rm -rv $argv ;;
      'rm'     ) rm -rv $argv ;;

      'copy'   ) cp -rv $argv ;;
      'cp'     ) cp -rv $argv ;;
   esac
fi

@odeke-em
Copy link
Owner

odeke-em commented Nov 5, 2015

Good one 👍

odeke-em added a commit that referenced this issue Apr 29, 2016
By default, rename will also rename the equivalent local path.
This CL also allows toggling whether to rename local or remote.
However, it resolves the file to change based off the remote path

- To turn off local renaming
```shell
$ drive rename --local=false a/b/c/d pam
```

- To turn off remote renaming
```shell
$ drive rename --remote=false bcd tkf
```

It also warns the user of an error if they turn off all modes.
```shell
$ drive rename --local=false --remote=false 5 6
no rename mode set, set either `local` or `remote` mode
$ echo $?
8
```

Fixes #459.
odeke-em added a commit that referenced this issue Apr 29, 2016
By default, rename will also rename the equivalent local path.
This CL also allows toggling whether to rename local or remote.
However, it resolves the file to change based off the remote path

- To turn off local renaming
```shell
$ drive rename --local=false a/b/c/d pam
```

- To turn off remote renaming
```shell
$ drive rename --remote=false bcd tkf
```

It also warns the user of an error if they turn off all modes.
```shell
$ drive rename --local=false --remote=false 5 6
no rename mode set, set either `local` or `remote` mode
$ echo $?
8
```

Fixes #459.
@odeke-em
Copy link
Owner

Hello @smblott-github, thank you for the patience. I got sometime finally tonight and implemented this with #632. Please get the latest.

@odeke-em odeke-em added this to the v0.3.6 milestone Apr 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants