>> add shell compatible runeset
> add flag to select runeset > update documentation
This commit is contained in:
parent
5232b8fb3b
commit
03d4c62e61
2 changed files with 49 additions and 7 deletions
43
main.go
43
main.go
|
|
@ -89,14 +89,23 @@ var FAT_RUNESET = runeset{
|
||||||
}
|
}
|
||||||
|
|
||||||
var POSIX_PORTABLE_RUNESET = runeset{
|
var POSIX_PORTABLE_RUNESET = runeset{
|
||||||
{ 0x2d, 0x2d },
|
{ 0x2d, 0x2e },
|
||||||
{ 0x2e, 0x2e },
|
|
||||||
{ 0x5f, 0x5f },
|
{ 0x5f, 0x5f },
|
||||||
{ 0x30, 0x39 },
|
{ 0x30, 0x39 },
|
||||||
{ 0x41, 0x5a },
|
{ 0x41, 0x5a },
|
||||||
{ 0x61, 0x7a },
|
{ 0x61, 0x7a },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var SHELL_RUNESET = runeset{
|
||||||
|
{ 0x25, 0x25 },
|
||||||
|
{ 0x2d, 0x2e },
|
||||||
|
{ 0x30, 0x39 },
|
||||||
|
{ 0x41, 0x5a },
|
||||||
|
{ 0x5f, 0x5f },
|
||||||
|
{ 0x61, 0x7a },
|
||||||
|
{ 0xc0, MAX_CODE_POINT },
|
||||||
|
}
|
||||||
|
|
||||||
/// MAIN FUNCTIONS
|
/// MAIN FUNCTIONS
|
||||||
/**
|
/**
|
||||||
* Compares paths so that all files come before the directories that contain
|
* Compares paths so that all files come before the directories that contain
|
||||||
|
|
@ -269,12 +278,26 @@ func parseCLIArgs(args []string) (context, error) {
|
||||||
result.Strategy = args[index]
|
result.Strategy = args[index]
|
||||||
case "-p", "--portable":
|
case "-p", "--portable":
|
||||||
result.Rset = POSIX_PORTABLE_RUNESET
|
result.Rset = POSIX_PORTABLE_RUNESET
|
||||||
|
case "-e", "--valid-set":
|
||||||
|
index++
|
||||||
|
switch args[index] {
|
||||||
|
case "fat":
|
||||||
|
result.Rset = FAT_RUNESET
|
||||||
|
case "posix":
|
||||||
|
result.Rset = POSIX_PORTABLE_RUNESET
|
||||||
|
case "shell":
|
||||||
|
result.Rset = SHELL_RUNESET
|
||||||
|
default:
|
||||||
|
return result, errors.New(
|
||||||
|
"Invalid character set! Please choose one of fat,posix,shell",
|
||||||
|
)
|
||||||
|
}
|
||||||
case "-c", "--replace":
|
case "-c", "--replace":
|
||||||
index++
|
index++
|
||||||
target, subs, ok := strings.Cut(args[index], ":")
|
target, subs, ok := strings.Cut(args[index], ":")
|
||||||
if !ok {
|
if !ok {
|
||||||
return result, errors.New(fmt.Sprintf(
|
return result, errors.New(fmt.Sprintf(
|
||||||
"Incorrect syntax (<<%s>>) for replacement: please use '{TARGET}:{REPLACEMNT1},{REPLACEMNT2},...'",
|
"Incorrect syntax (<<%s>>) for replacement: please use '{TARGET}:{REPLACEMENT1},{REPLACEMENT2},...'",
|
||||||
args[index],
|
args[index],
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
@ -322,13 +345,25 @@ func printHelp() {
|
||||||
(?,\,*,etc.) are removed.
|
(?,\,*,etc.) are removed.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-s,--strategy
|
-s,--strategy remove|represent
|
||||||
|
What to do with bad characters; either replace with a representation or
|
||||||
|
remove
|
||||||
-h,--help
|
-h,--help
|
||||||
|
Show this message
|
||||||
-v,--version
|
-v,--version
|
||||||
|
Show version
|
||||||
-r,--recurse DIRECTORY
|
-r,--recurse DIRECTORY
|
||||||
|
Recursively search for files in DIRECTORY with bad characters
|
||||||
-n,--dry-run
|
-n,--dry-run
|
||||||
|
Do not rename anything, just print what would be done
|
||||||
|
-t,--truncate LENGTH
|
||||||
|
Truncate all filenames to at most LENGTH bytes
|
||||||
|
-e,--valid-set fat|posix|shell
|
||||||
|
Select a set of characters to limit filenames to.
|
||||||
-p,--portable
|
-p,--portable
|
||||||
|
Alias for "--valid-set posix"
|
||||||
|
|
||||||
|
See man page for more details
|
||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
13
man.md
13
man.md
|
|
@ -32,10 +32,17 @@ includes DIRECTORY itself.
|
||||||
Causes Owl to just print a representation of what would be done without
|
Causes Owl to just print a representation of what would be done without
|
||||||
actually renaming any files.
|
actually renaming any files.
|
||||||
|
|
||||||
|
### -e,\-\-valid-set fat|posix|shell
|
||||||
|
Select which characters are considered "invalid" or "bad". Options are:
|
||||||
|
- fat: Characters which are valid in file names on FAT file systems. This
|
||||||
|
is the default.
|
||||||
|
- posix: The POSIX Portable Filename Character Set `A-Za-z0-9.-_`
|
||||||
|
- shell: Characters that *should* not need to be quoted when used in a
|
||||||
|
shell, i.e. all characters apart from control characters, whitespace, and
|
||||||
|
most punctuation.
|
||||||
|
|
||||||
### -p,\-\-portable
|
### -p,\-\-portable
|
||||||
Restrict characters to ones in the POSIX Portable Filename Character Set
|
An alias for "\-\-valid-set posix".
|
||||||
(see <https://pubs.opengroup.org/onlinepubs/9799919799/>, section 3.265)
|
|
||||||
instead of FAT compatible ones.
|
|
||||||
|
|
||||||
### -v, \-\-version
|
### -v, \-\-version
|
||||||
Show version information.
|
Show version information.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue