added wildcard into --skip switch

This commit is contained in:
2026-06-02 22:24:35 +02:00
parent 4e331d262a
commit d6118894a0
3 changed files with 132 additions and 35 deletions

View File

@ -48,8 +48,8 @@ php src/SFTPsync.php --host <host> --user <user> --password <password> [--port <
- `--port <port>`: optional, default `22`
- `--print-relative`: show paths relative to action root in logs
- `--no-print-skip`: suppress `SKIP` status lines during execution
- `--skip <file_or_dir>`: repeatable, applied to `--sync` and `--sync-down`
- `--skip-delete <file_or_dir>`: repeatable, applied to `--delete` and `--delete-dir`
- `--skip <pattern>`: repeatable, exact names/paths or glob patterns (`*`, `?`), applied to `--sync` and `--sync-down`
- `--skip-delete <pattern>`: repeatable, exact names/paths or glob patterns (`*`, `?`), applied to `--delete` and `--delete-dir`
- `-h`, `--help`: show help
## Examples
@ -69,7 +69,7 @@ php src/SFTPsync.php --host example.com --user u --password p \
# Skip selected entries during sync
php src/SFTPsync.php --host example.com --user u --password p \
--skip .git --skip node_modules --skip cache/tmp \
--skip .git --skip node_modules --skip "*.log" --skip "cache/*" \
--sync ./app /srv/app
# Delete remote directory but keep selected subpaths
@ -90,10 +90,22 @@ After upload/download, mtime is propagated to the target when possible.
## Skip Rule Matching
- Rule without slash (example: `node_modules`) matches any path segment with that name.
- Rule with slash (example: `cache/tmp`) matches that subpath within a relative path.
- Rule without wildcard characters (example: `node_modules`) keeps exact matching.
- Exact rule without slash (example: `node_modules`) matches any path segment with that name.
- Exact rule with slash (example: `cache/tmp`) matches that subpath within a relative path.
- Rule containing `*` or `?` is treated as a glob pattern. `*` matches any characters, and `?` matches one character.
- Glob rule without slash (example: `*.log`) can match file or directory names at any depth.
- Glob rule with slash (example: `src/temp/*.log` or `cache/*`) is matched against relative paths.
- Rules are normalized to forward slashes.
Examples:
- `--skip=*.bat` skips `test.bat` and `tools/deploy.bat`, but not `test.bat.txt`.
- `--skip=*.log` skips `app.log` and `src/temp/test.log`, but not `app.log.1`.
- `--skip=backup-*` skips `backup-2025`, `backup-old`, and `backup-test`.
- `--skip=cache/*` skips content under `cache`.
- `--skip=node_modules` and `--skip=.git` keep the original exact-name behavior.
## Safety Notes
- `--delete-dir` refuses dangerous roots such as empty path, `/`, `.`, `..`, and similar dot paths.