diff --git a/CHANGELOG.md b/CHANGELOG.md index 5049f82..3987317 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- `removemacai background` with an action other than `off` or `on`, such as the typo `of`, now fails and says which actions it takes, instead of listing the items and exiting 0 (#82). - The app is translated into Hindi and Urdu (#101). Urdu keeps the names of macOS screens and buttons in English, since macOS has no Urdu interface. - Block Music launches is now called Stop Music from opening, even by hand, and its warning says Music won't open at all until you undo it. The old name read as if only AirPods were blocked (#67). diff --git a/Sources/removemacai/SelfTest.swift b/Sources/removemacai/SelfTest.swift index 3d3073d..36712fc 100644 --- a/Sources/removemacai/SelfTest.swift +++ b/Sources/removemacai/SelfTest.swift @@ -42,6 +42,12 @@ func selfTest() -> Bool { check(unknownCommand.status == 1 && unknownCommandOutput.contains("error: unknown command \"stauts\"") && unknownCommandOutput.contains("Did you mean \"status\"?"), "an unknown command fails naming the typo instead of printing bare usage") + let unknownAction = Shell.run(executable, ["background", "of"]) + let unknownActionOutput = unknownAction.output.replacingOccurrences( + of: #"\x1B\[[0-9;]*m"#, with: "", options: .regularExpression) + check(unknownAction.status == 1 + && unknownActionOutput.trimmingCharacters(in: .whitespacesAndNewlines) == "error: unknown action \"of\", use off or on", + "background fails on an unknown action instead of listing items") check(Set(Catalog.setsToRemove(keeping: [])) == Set(Catalog.availableModelSets.map(\.name)), "off removes every model set this macOS has") diff --git a/Sources/removemacai/TweakCommands.swift b/Sources/removemacai/TweakCommands.swift index ca592bf..d87e674 100644 --- a/Sources/removemacai/TweakCommands.swift +++ b/Sources/removemacai/TweakCommands.swift @@ -136,9 +136,12 @@ enum TweakCommands { // MARK: background items static func background(_ args: [String], yes: Bool) -> Bool { + if let action = args.first, action != "off" && action != "on" { + Term.fail("unknown action \"\(action)\", use off or on") + } let items = BackgroundItems.scan() let labels = BackgroundItems.disabledLabels() - guard let action = args.first, action == "off" || action == "on" else { + guard let action = args.first else { Commands.header() if items.isEmpty { print("No background items from other apps.")