Skip to content

Commit

Permalink
add informative output message about channel add/remove result
Browse files Browse the repository at this point in the history
  • Loading branch information
memo33 committed May 15, 2024
1 parent 9a8bdab commit b552975
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 16 additions & 2 deletions src/main/scala/sc4pac/cli.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
}
Expand Down Expand Up @@ -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(()))
Expand Down

0 comments on commit b552975

Please sign in to comment.