2
0
mirror of https://github.com/meganz/MEGAcmd synced 2025-09-01 06:15:09 +00:00

Add help for the sync-ignore command

Also update help for the exclude command to reflect the latest changes.
This commit is contained in:
Diego Ximenez
2024-08-13 18:07:35 +02:00
parent 16d31b36cc
commit f7e17150bc
5 changed files with 103 additions and 15 deletions

View File

@@ -216,7 +216,8 @@ Verbosity: You can increase the amount of information given by any command by pa
* [`transfers`](contrib/docs/commands/transfers.md)`[-c TAG|-a] | [-r TAG|-a] | [-p TAG|-a] [--only-downloads | --only-uploads] [SHOWOPTIONS]` List or operate with transfers
* [`speedlimit`](contrib/docs/commands/speedlimit.md)`[-u|-d] [-h] [NEWLIMIT]` Displays/modifies upload/download rate limits
* [`sync`](contrib/docs/commands/sync.md)`[localpath dstremotepath| [-dsr] [ID|localpath]` Controls synchronizations.
* [`exclude`](contrib/docs/commands/exclude.md)`[(-a|-d) pattern1 pattern2 pattern3]` Manages exclusions in syncs.
* [`sync-ignore`](contrib/docs/commands/sync-ignore.md)`[--show|--add [filter1 filter2 ...]|--remove [filter1 filter2 ...]] (ID|localpath)` Manages ignore filters for syncs
* [`exclude`](contrib/docs/commands/exclude.md)`[(-a|-d) pattern1 pattern2 pattern3]` Manages default exclusion rules in syncs.
* [`backup`](contrib/docs/commands/backup.md)`(localpath remotepath --period="PERIODSTRING" --num-backups=N | [-lhda] [TAG|localpath] [--period="PERIODSTRING"] [--num-backups=N]) [--time-format=FORMAT]` Controls backups
### Sharing (your own files, of course, without infringing any copyright)

View File

@@ -1,15 +1,14 @@
### exclude
Manages exclusions in syncs.
Manages default exclusion rules in syncs.
Usage: `exclude [(-a|-d) pattern1 pattern2 pattern3]`
<pre>
These default rules will be used when creating new syncs. Existing syncs won't be affected. To modify the exclusion rules of existing syncs, use sync-ignore.
Options:
-a pattern1 pattern2 ... adds pattern(s) to the exclusion list
(* and ? wildcards allowed)
-d pattern1 pattern2 ... deletes pattern(s) from the exclusion list
Caveat: removal of patterns may not trigger sync transfers right away.
Consider:
a) disable/reenable synchronizations manually
b) restart MEGAcmd server
This command is DEPRECATED. Use sync-ignore instead.
</pre>

View File

@@ -0,0 +1,46 @@
### sync-ignore
Manages ignore filters for syncs
Usage: `sync-ignore [--show|--add [filter1 filter2 ...]|--remove [filter1 filter2 ...]] (ID|localpath)`
<pre>
If no path or sync ID is provided, the default mega ignore filters will be selected.
Note: when modifying the default filters, existing syncs won't be affected. Only newly created ones.
If no action is provided, filters will be shown for the selected sync.
Options:
--show Show the existing filters of the selected sync
--add Add the specified filters to the selected sync
--remove Remove the specified filters from the selected sync
Filters must have the following format: <CLASS><TARGET><TYPE><STRATEGY>:<PATTERN>
<CLASS> Must be either exclude, or include
exclude (`-`): This filter contains files or directories that *should not* be synchronized
include (`+`): This filter contains files or directories that *should* be synchronized
<TARGET> May be one of the following: directory, file, symlink, or all
directory (`d`): This filter applies only to directories
file (`f`): This filter applies only to files
symlink (`s`): This filter applies only to symbolic links
all (`a`): This filter applies to all of the above
Default is `a`
<TYPE> May be one of the following: local name, path, or subtree name
local name (`N`): This filter has an effect only in the root directory of the sync
path (`p`): This filter matches against the path relative to the rooth directory of the sync
Note: the path separator is always '/', even on Windows
subtree name (`n`): This filter has an effect in all directories below the root directory of the sync, itself included
Default is `n`
<STRATEGY> May be one of the following: glob, or regexp
glob (`G` or `g`): This filter matches against a name or path using a wildcard pattern
regexp (`R` or `r`): This filter matches against a name or path using a pattern expressed as a POSIX-Extended Regular Expression
Note: uppercase `G` or `R` specifies that the matching should be case-sensitive
Default is `G`
<PATTERN> Must be a file or directory pattern
Some examples:
`-f:*.txt` Filter will exclude all *.txt files in and beneath the sync directory
`+fg:work*.txt` Filter will include all work*.txt files excluded by the filter above
`-N:*.avi` Filter will exclude all *.avi files contained directly in the sync directory
`-nr:.*foo.*` Filter will exclude files whose name contains 'foo'
`-d:private` Filter will exclude all directories with the name 'private'
See: https://help.mega.io/installs-apps/desktop/megaignore more info.
</pre>

View File

@@ -60,10 +60,10 @@ class CommandTable:
command_lines = command_detail.split('\n', maxsplit=3)
# Does not start with <command_name>; not a command
if not re.match(r'<\w+>', command_lines[0]):
if not re.match(r'<[\w-]+>', command_lines[0]):
return
command_name = re.search(r'<(\w+)>', command_lines[0]).group(1)
command_name = re.search(r'<([\w-]+)>', command_lines[0]).group(1)
usage = re.search(r'Usage: (.+)', command_lines[1]).group(1)
summary = command_lines[2]
description = command_lines[3] if len(command_lines) > 3 else ''
@@ -116,7 +116,7 @@ def get_commands_by_category(ct):
'Account / Contacts': ['signup', 'confirm', 'invite', 'showpcr', 'ipc', 'users', 'userattr', 'passwd', 'masterkey'],
'Login / Logout': ['login', 'logout', 'whoami', 'session', 'killsession'],
'Browse': ['cd', 'lcd', 'ls', 'pwd', 'lpwd', 'attr', 'du', 'find', 'mount'],
'Moving / Copying files': ['mkdir', 'cp', 'put', 'get', 'preview', 'thumbnail', 'mv', 'rm', 'transfers', 'speedlimit', 'sync', 'exclude', 'backup'],
'Moving / Copying files': ['mkdir', 'cp', 'put', 'get', 'preview', 'thumbnail', 'mv', 'rm', 'transfers', 'speedlimit', 'sync', 'sync-ignore', 'exclude', 'backup'],
'Sharing (your own files, of course, without infringing any copyright)': ['export', 'import', 'share', 'webdav'],
}

View File

@@ -2504,18 +2504,15 @@ string getHelpStr(const char *command, const HelpFlags& flags = {})
}
else if (!strcmp(command, "exclude"))
{
os << "Manages exclusions in syncs." << endl;
os << "Manages default exclusion rules in syncs." << endl;
os << "These default rules will be used when creating new syncs. Existing syncs won't be affected. To modify the exclusion rules of existing syncs, use sync-ignore." << endl;
os << endl;
os << "Options:" << endl;
os << " -a pattern1 pattern2 ..." << "\t" << "adds pattern(s) to the exclusion list" << endl;
os << " " << "\t" << " (* and ? wildcards allowed)" << endl;
os << " -d pattern1 pattern2 ..." << "\t" << "deletes pattern(s) from the exclusion list" << endl;
os << endl;
os << "Caveat: removal of patterns may not trigger sync transfers right away." << endl;
os << "Consider:" << endl;
os << " a) disable/reenable synchronizations manually" << endl;
os << " b) restart MEGAcmd server" << endl;
os << "This command is DEPRECATED. Use sync-ignore instead." << endl;
}
else if (!strcmp(command, "sync"))
{
@@ -2554,6 +2551,51 @@ string getHelpStr(const char *command, const HelpFlags& flags = {})
os << " " << "ERROR: Error, if any." << endl;
os << " " << "SIZE, FILE & DIRS: size, number of files and number of dirs in the remote folder." << endl;
}
else if (!strcmp(command, "sync-ignore"))
{
os << "Manages ignore filters for syncs" << endl;
os << endl;
os << "If no path or sync ID is provided, the default mega ignore filters will be selected." << endl;
os << "Note: when modifying the default filters, existing syncs won't be affected. Only newly created ones." << endl;
os << endl;
os << "If no action is provided, filters will be shown for the selected sync." << endl;
os << endl;
os << "Options:" << endl;
os << "--show" << "\t" << "Show the mega ignore filters for the selected sync" << endl;
os << "--add" << "\t" << "Add the specified filters to the selected sync" << endl;
os << "--remove" << "\t" << "Remove the specified filters from the selected sync" << endl;
os << endl;
os << "Filters must have the following format: <CLASS><TARGET><TYPE><STRATEGY>:<PATTERN>" << endl;
os << "\t" << "<CLASS> Must be either exclude, or include" << endl;
os << "\t" << "\t" << "exclude (`-`): This filter contains files or directories that *should not* be synchronized" << endl;
os << "\t" << "\t" << "include (`+`): This filter contains files or directories that *should* be synchronized" << endl;
os << "\t" << "<TARGET> May be one of the following: directory, file, symlink, or all" << endl;
os << "\t" << "\t" << "directory (`d`): This filter applies only to directories" << endl;
os << "\t" << "\t" << "file (`f`): This filter applies only to files" << endl;
os << "\t" << "\t" << "symlink (`s`): This filter applies only to symbolic links" << endl;
os << "\t" << "\t" << "all (`a`): This filter applies to all of the above" << endl;
os << "\t" << "Default is `a`" << endl;
os << "\t" << "<TYPE> May be one of the following: local name, path, or subtree name" << endl;
os << "\t" << "\t" << "local name (`N`): This filter has an effect only in the root directory of the sync" << endl;
os << "\t" << "\t" << "path (`p`): This filter matches against the path relative to the rooth directory of the sync" << endl;
os << "\t" << "\t" << " Note: the path separator is always '/', even on Windows" << endl;
os << "\t" << "\t" << "subtree name (`n`): This filter has an effect in all directories below the root directory of the sync, itself included" << endl;
os << "\t" << "Default is `n`" << endl;
os << "\t" << "<STRATEGY> May be one of the following: glob, or regexp" << endl;
os << "\t" << "\t" << "glob (`G` or `g`): This filter matches against a name or path using a wildcard pattern" << endl;
os << "\t" << "\t" << "regexp (`R` or `r`): This filter matches against a name or path using a pattern expressed as a POSIX-Extended Regular Expression" << endl;
os << "\t" << "Note: uppercase `G` or `R` specifies that the matching should be case-sensitive" << endl;
os << "\t" << "Default is `G`" << endl;
os << "\t" << "<PATTERN> Must be a file or directory pattern" << endl;
os << "Some examples:" << endl;
os << "\t" << "`-f:*.txt`" << " " << "Filter will exclude all *.txt files in and beneath the sync directory" << endl;
os << "\t" << "`+fg:work*.txt`" << " " << "Filter will include all work*.txt files excluded by the filter above" << endl;
os << "\t" << "`-N:*.avi`" << " " << "Filter will exclude all *.avi files contained directly in the sync directory" << endl;
os << "\t" << "`-nr:.*foo.*`" << " " << "Filter will exclude files whose name contains 'foo'" << endl;
os << "\t" << "`-d:private`" << " " << "Filter will exclude all directories with the name 'private'" << endl;
os << endl;
os << "See: https://help.mega.io/installs-apps/desktop/megaignore more info." << endl;
}
else if (!strcmp(command, "backup"))
{
os << "Controls backups" << endl;