diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fed7db..17ec9a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,11 +6,14 @@ - warning about outdated metadata, in case an inclusion/exclusion pattern does not match any files in an Asset anymore. - support for rendering package identifiers in metadata description text, using syntax `` `pkg=group:name` ``. +### Changed +- The `channel add/remove` commands now show a message about the result of the command. + ### Fixed - a bug causing assets containing Clickteam installers to be reinstalled whenever running `sc4pac update`. - an error arising when building a channel containing empty YAML documents. The error handling for syntactically invalid YAML files is more graceful now, as well. -- the dates in the `lastModified` field are now more lenient in terms of surrounding whitespace. +- The dates in the `lastModified` field are now more lenient in terms of surrounding whitespace. ## [0.4.2] - 2024-04-18 diff --git a/src/main/scala/sc4pac/cli.scala b/src/main/scala/sc4pac/cli.scala index 5910170..4449df1 100644 --- a/src/main/scala/sc4pac/cli.scala +++ b/src/main/scala/sc4pac/cli.scala @@ -327,7 +327,14 @@ object Commands { | |Examples: | sc4pac channel add "${Constants.defaultChannelUrls.head}" - | sc4pac channel add "file:///c:/absolute/path/to/local/channel/" + | sc4pac channel add "file:///C:/absolute/path/to/local/channel/" + | + |The URL in the examples above points to a directory structure consisting of JSON files created by the ${emph("sc4pac channel build")} command. + | + |For convenience, the channel URL may also point to a single YAML file instead, which skips the ${emph("sc4pac channel build")} step. This is mainly intended for testing purposes. + | + | sc4pac channel add "file:///C:/Users/Dumbledore/Desktop/hogwarts-castle.yaml" + | sc4pac channel add "https://raw.githubusercontent.com/memo33/sc4pac/main/docs/hogwarts-castle.yaml" """.stripMargin.trim) final case class ChannelAddOptions() extends Sc4pacCommandOptions @@ -347,6 +354,8 @@ object Commands { data2 = data.copy(config = data.config.copy(channels = (data.config.channels :+ uri).distinct)) path <- JD.Plugins.pathURIO _ <- JsonIo.write(path, data2, None)(ZIO.succeed(())) + count = data2.config.channels.length - data.config.channels.length + _ <- ZIO.succeed{ println(if (count == 0) "Channel already exists." else s"Added 1 channel.") } } yield () runMainExit(task.provideEnvironment(cliEnvironment), exit) } @@ -390,7 +399,12 @@ object Commands { ZIO.succeed((url: java.net.URI) => args.all.exists(pattern => url.toString.contains(pattern))) } (drop, keep) = data.config.channels.partition(isSelected) - _ <- ZIO.succeed { if (drop.nonEmpty) println(("The following channels have been removed:" +: drop).mkString(f"%n")) } + _ <- ZIO.succeed { + if (drop.nonEmpty) + println(("The following channels have been removed:" +: drop).mkString(f"%n")) + else + println("No matching channel found, so none of the channels have been removed.") + } data2 = data.copy(config = data.config.copy(channels = keep)) path <- JD.Plugins.pathURIO _ <- JsonIo.write(path, data2, None)(ZIO.succeed(()))