>> remove more complex whitespace behaviour form tests
> make restrictRuneset pass tests
This commit is contained in:
parent
3fcb56c584
commit
13e6010d04
4 changed files with 14 additions and 20 deletions
4
Makefile
4
Makefile
|
|
@ -5,4 +5,6 @@ owl: ${SOURCES}
|
||||||
owl.1: man.md
|
owl.1: man.md
|
||||||
pandoc -s --shift-heading-level-by=-1 --to=man man.md > owl.1
|
pandoc -s --shift-heading-level-by=-1 --to=man man.md > owl.1
|
||||||
build: owl owl.1
|
build: owl owl.1
|
||||||
.PHONY: build
|
test: *.go
|
||||||
|
go test -v .
|
||||||
|
.PHONY: build test
|
||||||
|
|
|
||||||
8
main.go
8
main.go
|
|
@ -91,13 +91,16 @@ func restrictRuneset(s, strategy string) string {
|
||||||
} else {
|
} else {
|
||||||
for _, r := range result {
|
for _, r := range result {
|
||||||
if !isFatValid(r) {
|
if !isFatValid(r) {
|
||||||
toValidSubs[r] = fmt.Sprintf("_U%d_", r)
|
toValidSubs[r] = fmt.Sprintf("_U%X_", r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for old, new := range toValidSubs {
|
for old, new := range toValidSubs {
|
||||||
result = strings.ReplaceAll(result, string(old), new)
|
result = strings.ReplaceAll(result, string(old), new)
|
||||||
}
|
}
|
||||||
|
if len(result) == 0 {
|
||||||
|
return "_EMPTY_"
|
||||||
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -159,7 +162,7 @@ func parseCLIArgs(args []string) (context, error) {
|
||||||
|
|
||||||
// TODO: Finish writing options short help. Mention man page where relevant.
|
// TODO: Finish writing options short help. Mention man page where relevant.
|
||||||
func printHelp() {
|
func printHelp() {
|
||||||
fmt.Println(`Owl - a hunter of bad characters in filenames
|
fmt.Print(`Owl - a hunter of bad characters in filenames
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
owl [options] FILES
|
owl [options] FILES
|
||||||
|
|
@ -172,6 +175,7 @@ func printHelp() {
|
||||||
-h,--help
|
-h,--help
|
||||||
-v,--version
|
-v,--version
|
||||||
-d,--directory DIRECTORY
|
-d,--directory DIRECTORY
|
||||||
|
|
||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
20
man.md
20
man.md
|
|
@ -9,39 +9,27 @@ not compatible with `FAT` file systems (typically `FAT32` or `exFAT`).
|
||||||
owl COMMAND OPTIONS FILE1 FILE2 ...
|
owl COMMAND OPTIONS FILE1 FILE2 ...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## CLEAN COMMAND
|
|
||||||
Rename `FILE`s given at the command line such that all `FAT`-incompatible
|
Rename `FILE`s given at the command line such that all `FAT`-incompatible
|
||||||
characters are removed. By default it replaces invalid characters with
|
characters are removed. By default it replaces invalid characters with
|
||||||
`_U{Unicode Code Point}_`, but this can be changed, see the `--strategy`
|
`_U{Unicode Code Point}_`, but this can be changed, see the `--strategy`
|
||||||
flag below.
|
flag below.
|
||||||
|
|
||||||
## Options:
|
|
||||||
|
|
||||||
|
## Options:
|
||||||
### -s, --strategy STRATEGY
|
### -s, --strategy STRATEGY
|
||||||
Change what happens to invalid characters. Choices are:
|
Change what happens to invalid characters. Choices are:
|
||||||
|
|
||||||
- "remove": just remove the characters. If left with an empty string, rename
|
- "remove": just remove the characters. If left with an empty string, rename
|
||||||
to "\_empty_".
|
to "\_empty_".
|
||||||
- "code-point": replace each character with "\_Unum_", where "num" is the
|
- "represent": replace each character with "\_Unum_", where "num" is the
|
||||||
Unicode Code Point of the character.
|
Unicode Code Point of the character.
|
||||||
|
|
||||||
## HELP COMMAND
|
|
||||||
Show a small help message.
|
|
||||||
|
|
||||||
## VERSION COMMAND
|
|
||||||
Show version information.
|
|
||||||
|
|
||||||
|
|
||||||
## GENERAL OPTIONS
|
|
||||||
### -n, --dry-run
|
### -n, --dry-run
|
||||||
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.
|
||||||
|
|
||||||
### -v, --version
|
### -v, --version
|
||||||
Causes the `version` command to be run, regardless of what other arguments
|
Show version information.
|
||||||
are given.
|
|
||||||
|
|
||||||
### -h, --help
|
### -h, --help
|
||||||
Causes the `help` command to be run, regardless of what other arguments are
|
Show a small help message.
|
||||||
given.
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue