>> 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
|
||||
pandoc -s --shift-heading-level-by=-1 --to=man man.md > 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 {
|
||||
for _, r := range result {
|
||||
if !isFatValid(r) {
|
||||
toValidSubs[r] = fmt.Sprintf("_U%d_", r)
|
||||
toValidSubs[r] = fmt.Sprintf("_U%X_", r)
|
||||
}
|
||||
}
|
||||
}
|
||||
for old, new := range toValidSubs {
|
||||
result = strings.ReplaceAll(result, string(old), new)
|
||||
}
|
||||
if len(result) == 0 {
|
||||
return "_EMPTY_"
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
|
|
@ -159,7 +162,7 @@ func parseCLIArgs(args []string) (context, error) {
|
|||
|
||||
// TODO: Finish writing options short help. Mention man page where relevant.
|
||||
func printHelp() {
|
||||
fmt.Println(`Owl - a hunter of bad characters in filenames
|
||||
fmt.Print(`Owl - a hunter of bad characters in filenames
|
||||
|
||||
Usage:
|
||||
owl [options] FILES
|
||||
|
|
@ -172,6 +175,7 @@ func printHelp() {
|
|||
-h,--help
|
||||
-v,--version
|
||||
-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 ...
|
||||
```
|
||||
|
||||
|
||||
## CLEAN COMMAND
|
||||
Rename `FILE`s given at the command line such that all `FAT`-incompatible
|
||||
characters are removed. By default it replaces invalid characters with
|
||||
`_U{Unicode Code Point}_`, but this can be changed, see the `--strategy`
|
||||
flag below.
|
||||
|
||||
## Options:
|
||||
|
||||
## Options:
|
||||
### -s, --strategy STRATEGY
|
||||
Change what happens to invalid characters. Choices are:
|
||||
|
||||
- "remove": just remove the characters. If left with an empty string, rename
|
||||
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.
|
||||
|
||||
## HELP COMMAND
|
||||
Show a small help message.
|
||||
|
||||
## VERSION COMMAND
|
||||
Show version information.
|
||||
|
||||
|
||||
## GENERAL OPTIONS
|
||||
### -n, --dry-run
|
||||
Causes Owl to just print a representation of what would be done without
|
||||
actually renaming any files.
|
||||
|
||||
### -v, --version
|
||||
Causes the `version` command to be run, regardless of what other arguments
|
||||
are given.
|
||||
Show version information.
|
||||
|
||||
### -h, --help
|
||||
Causes the `help` command to be run, regardless of what other arguments are
|
||||
given.
|
||||
Show a small help message.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue