Skip to content

Commit 3adaf31

Browse files
committed
Add conflict handling to upload and download commands
1 parent 6e60516 commit 3adaf31

File tree

4 files changed

+257
-94
lines changed

4 files changed

+257
-94
lines changed

docs/index.rst

Lines changed: 81 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -105,67 +105,68 @@ Command line syntax
105105

106106
Use the ``--help`` or ``-h`` argument to get help::
107107

108-
$ pyftpsync -h
109-
usage: pyftpsync [-h] [--verbose | --quiet] [--version] [--progress]
110-
{upload,download,sync} ...
111-
112-
Synchronize folders over FTP.
113-
114-
positional arguments:
115-
{upload,download,sync}
116-
sub-command help
117-
upload copy new and modified files to remote folder
118-
download copy new and modified files from remote folder to
119-
local target
120-
sync synchronize new and modified files between remote
121-
folder and local target
122-
123-
optional arguments:
124-
-h, --help show this help message and exit
125-
--verbose, -v increment verbosity by one (default: 3, range: 0..5)
126-
--quiet, -q decrement verbosity by one
127-
--version show program's version number and exit
128-
--progress, -p show progress info, even if redirected or verbose < 3
129-
130-
See also https://github.com/mar10/pyftpsync
131-
$
108+
$ pyftpsync -h
109+
usage: pyftpsync [-h] [--verbose | --quiet] [--version] [--progress]
110+
{upload,download,sync} ...
111+
112+
Synchronize folders over FTP.
113+
114+
positional arguments:
115+
{upload,download,sync}
116+
sub-command help
117+
upload copy new and modified files to remote folder
118+
download copy new and modified files from remote folder to
119+
local target
120+
sync synchronize new and modified files between remote
121+
folder and local target
122+
123+
optional arguments:
124+
-h, --help show this help message and exit
125+
--verbose, -v increment verbosity by one (default: 3, range: 0..5)
126+
--quiet, -q decrement verbosity by one
127+
--version show program's version number and exit
128+
--progress, -p show progress info, even if redirected or verbose < 3
129+
$
132130

133131

134132
Upload files syntax
135133
-------------------
136134

137135
Command specific help is available like so::
138136

139-
$ pyftpsync upload --help
140-
usage: pyftpsync upload [-h] [-x] [-f INCLUDE_FILES] [-o OMIT]
141-
[--store-password] [--no-prompt] [--no-color]
142-
[--force] [--delete] [--delete-unmatched]
143-
LOCAL REMOTE
144-
145-
positional arguments:
146-
LOCAL path to local folder (default: .)
147-
REMOTE path to remote folder
148-
149-
optional arguments:
150-
-h, --help show this help message and exit
151-
-x, --execute turn off the dry-run mode (which is ON by default),
152-
that would just print status messages but does not
153-
change anything
154-
-f INCLUDE_FILES, --include-files INCLUDE_FILES
155-
wildcard for file names (default: all, separate
156-
multiple values with ',')
157-
-o OMIT, --omit OMIT wildcard of files and directories to exclude (applied
158-
after --include)
159-
--store-password save password to keyring if login succeeds
160-
--no-prompt prevent prompting for missing credentials
161-
--no-color prevent use of ansi terminal color codes
162-
--force overwrite different remote files, even if the target
163-
is newer
164-
--delete remove remote files if they don't exist locally
165-
--delete-unmatched remove remote files if they don't exist locally or
166-
don't match the current filter (implies '--delete'
167-
option)
168-
$
137+
$ pyftpsync upload --help
138+
usage: pyftpsync upload [-h] [-x] [-f INCLUDE_FILES] [-o OMIT]
139+
[--store-password] [--no-prompt] [--no-color]
140+
[--force] [--resolve {local,skip,ask}] [--delete]
141+
[--delete-unmatched]
142+
LOCAL REMOTE
143+
144+
positional arguments:
145+
LOCAL path to local folder (default: .)
146+
REMOTE path to remote folder
147+
148+
optional arguments:
149+
-h, --help show this help message and exit
150+
-x, --execute turn off the dry-run mode (which is ON by default),
151+
that would just print status messages but does not
152+
change anything
153+
-f INCLUDE_FILES, --include-files INCLUDE_FILES
154+
wildcard for file names (default: all, separate
155+
multiple values with ',')
156+
-o OMIT, --omit OMIT wildcard of files and directories to exclude (applied
157+
after --include)
158+
--store-password save password to keyring if login succeeds
159+
--no-prompt prevent prompting for missing credentials
160+
--no-color prevent use of ansi terminal color codes
161+
--force overwrite remote files, even if the target is newer
162+
(but no conflict was detected)
163+
--resolve {local,skip,ask}
164+
conflict resolving strategy (default: 'skip')
165+
--delete remove remote files if they don't exist locally
166+
--delete-unmatched remove remote files if they don't exist locally or
167+
don't match the current filter (implies '--delete'
168+
option)
169+
$
169170

170171
Example: Upload files
171172
---------------------
@@ -189,32 +190,32 @@ Synchronize files syntax
189190
------------------------
190191
::
191192

192-
$ pyftpsync sync --help
193-
usage: pyftpsync sync [-h] [-x] [-f INCLUDE_FILES] [-o OMIT]
194-
[--store-password] [--no-prompt] [--no-color]
195-
[--resolve {old,new,local,remote,ask}]
196-
LOCAL REMOTE
197-
198-
positional arguments:
199-
LOCAL path to local folder (default: .)
200-
REMOTE path to remote folder
201-
202-
optional arguments:
203-
-h, --help show this help message and exit
204-
-x, --execute turn off the dry-run mode (which is ON by default),
205-
that would just print status messages but does not
206-
change anything
207-
-f INCLUDE_FILES, --include-files INCLUDE_FILES
208-
wildcard for file names (default: all, separate
209-
multiple values with ',')
210-
-o OMIT, --omit OMIT wildcard of files and directories to exclude (applied
211-
after --include)
212-
--store-password save password to keyring if login succeeds
213-
--no-prompt prevent prompting for missing credentials
214-
--no-color prevent use of ansi terminal color codes
215-
--resolve {old,new,local,remote,ask}
216-
conflict resolving strategy
217-
$
193+
$ pyftpsync sync --help
194+
usage: pyftpsync sync [-h] [-x] [-f INCLUDE_FILES] [-o OMIT]
195+
[--store-password] [--no-prompt] [--no-color]
196+
[--resolve {old,new,local,remote,skip,ask}]
197+
LOCAL REMOTE
198+
199+
positional arguments:
200+
LOCAL path to local folder (default: .)
201+
REMOTE path to remote folder
202+
203+
optional arguments:
204+
-h, --help show this help message and exit
205+
-x, --execute turn off the dry-run mode (which is ON by default),
206+
that would just print status messages but does not
207+
change anything
208+
-f INCLUDE_FILES, --include-files INCLUDE_FILES
209+
wildcard for file names (default: all, separate
210+
multiple values with ',')
211+
-o OMIT, --omit OMIT wildcard of files and directories to exclude (applied
212+
after --include)
213+
--store-password save password to keyring if login succeeds
214+
--no-prompt prevent prompting for missing credentials
215+
--no-color prevent use of ansi terminal color codes
216+
--resolve {old,new,local,remote,skip,ask}
217+
conflict resolving strategy (default: 'ask')
218+
$
218219

219220
Example: Synchronize folders
220221
----------------------------

ftpsync/pyftpsync.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ def __add_common_sub_args(parser):
108108

109109
upload_parser.add_argument("--force",
110110
action="store_true",
111-
help="overwrite different remote files, even if the target is newer")
111+
help="overwrite remote files, even if the target is newer (but no conflict was detected)")
112+
upload_parser.add_argument("--resolve",
113+
default="skip",
114+
choices=["local", "skip", "ask"],
115+
help="conflict resolving strategy (default: '%(default)s')")
112116
upload_parser.add_argument("--delete",
113117
action="store_true",
114118
help="remove remote files if they don't exist locally")
@@ -127,7 +131,11 @@ def __add_common_sub_args(parser):
127131

128132
download_parser.add_argument("--force",
129133
action="store_true",
130-
help="overwrite different local files, even if the target is newer")
134+
help="overwrite local files, even if the target is newer (but no conflict was detected)")
135+
download_parser.add_argument("--resolve",
136+
default="skip",
137+
choices=["remote", "skip", "ask"],
138+
help="conflict resolving strategy (default: '%(default)s')")
131139
download_parser.add_argument("--delete",
132140
action="store_true",
133141
help="remove local files if they don't exist on remote target")
@@ -143,19 +151,10 @@ def __add_common_sub_args(parser):
143151
help="synchronize new and modified files between remote folder and local target")
144152
__add_common_sub_args(sync_parser)
145153

146-
# sync_parser.add_argument("--store-password",
147-
# action="store_true",
148-
# help="save password to keyring if login succeeds")
149-
# sync_parser.add_argument("--no-prompt",
150-
# action="store_true",
151-
# help="prevent prompting for missing credentials")
152-
# sync_parser.add_argument("--no-color",
153-
# action="store_true",
154-
# help="prevent use of ansi terminal color codes")
155154
sync_parser.add_argument("--resolve",
156155
default="ask",
157156
choices=["old", "new", "local", "remote", "skip", "ask"],
158-
help="conflict resolving strategy (default: 'ask')")
157+
help="conflict resolving strategy (default: '%(default)s')")
159158

160159
sync_parser.set_defaults(command="synchronize")
161160

0 commit comments

Comments
 (0)